<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The GRASP/AQUA Project, Glasgow University, 1993-1998

\section[Specialise]{Stamping out overloading, and (optionally) polymorphism}
-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# LANGUAGE PatternSynonyms #-}</span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# LANGUAGE DeriveFunctor #-}</span><span>
</span><span id="line-10"></span><span class="hs-pragma">{-# LANGUAGE ViewPatterns #-}</span><span>
</span><span id="line-11"></span><span>
</span><span id="line-12"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}</span><span>
</span><span id="line-13"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Core.Opt.Specialise</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specProgram"><span class="hs-identifier">specProgram</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unfold.html#specUnfolding"><span class="hs-identifier">specUnfolding</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span> </span><span class="hs-keyword">hiding</span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier">substTy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>  </span><span class="hs-keyword">hiding</span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier">substTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstList"><span class="hs-identifier">extendTvSubstList</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html"><span class="hs-identifier">GHC.Core.Predicate</span></a></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html"><span class="hs-identifier">GHC.Unit.Module</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier">Module</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html#HasModule"><span class="hs-identifier">HasModule</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier">Coercion</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html"><span class="hs-identifier">GHC.Core.Opt.Monad</span></a></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html"><span class="hs-identifier">GHC.Core.Subst</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Core</span></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Unfold.html"><span class="hs-identifier">GHC.Core.Unfold</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>      </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#isLocalVar"><span class="hs-identifier">isLocalVar</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Rules.html"><span class="hs-identifier">GHC.Core.Rules</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.SimpleOpt.html"><span class="hs-identifier">GHC.Core.SimpleOpt</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.SimpleOpt.html#collectBindersPushingCo"><span class="hs-identifier">collectBindersPushingCo</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html"><span class="hs-identifier">GHC.Core.Utils</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#exprIsTrivial"><span class="hs-identifier">exprIsTrivial</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#getIdFromTrivialExpr_maybe"><span class="hs-identifier">getIdFromTrivialExpr_maybe</span></a></span><span>
</span><span id="line-36"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#mkCast"><span class="hs-identifier">mkCast</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier">exprType</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html"><span class="hs-identifier">GHC.Core.FVs</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html"><span class="hs-identifier">GHC.Core.Opt.Arity</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaExpandToJoinPointRule"><span class="hs-identifier">etaExpandToJoinPointRule</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html"><span class="hs-identifier">GHC.Types.Unique.Supply</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Make.html"><span class="hs-identifier">GHC.Types.Id.Make</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Id.Make.html#voidArgId"><span class="hs-identifier">voidArgId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.Make.html#voidPrimId"><span class="hs-identifier">voidPrimId</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.Prim.html"><span class="hs-identifier">GHC.Builtin.Types.Prim</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.Prim.html#voidPrimTy"><span class="hs-identifier">voidPrimTy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#mapMaybe"><span class="hs-identifier">mapMaybe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#maybeToList"><span class="hs-identifier">maybeToList</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier">isJust</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html"><span class="hs-identifier">GHC.Utils.Monad</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier">foldlM</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html"><span class="hs-identifier">GHC.Driver.Types</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.State.html"><span class="hs-identifier">GHC.Utils.Monad.State</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.DFM.html"><span class="hs-identifier">GHC.Types.Unique.DFM</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyCoBinder"><span class="hs-identifier">TyCoBinder</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection[notes-Specialise]{Implementation notes [SLPJ, Aug 18 1993]}
*                                                                      *
************************************************************************

These notes describe how we implement specialisation to eliminate
overloading.

The specialisation pass works on Core
syntax, complete with all the explicit dictionary application,
abstraction and construction as added by the type checker.  The
existing type checker remains largely as it is.

One important thought: the {\em types} passed to an overloaded
function, and the {\em dictionaries} passed are mutually redundant.
If the same function is applied to the same type(s) then it is sure to
be applied to the same dictionary(s)---or rather to the same {\em
values}.  (The arguments might look different but they will evaluate
to the same value.)

Second important thought: we know that we can make progress by
treating dictionary arguments as static and worth specialising on.  So
we can do without binding-time analysis, and instead specialise on
dictionary arguments and no others.

The basic idea
~~~~~~~~~~~~~~
Suppose we have

        let f = &lt;f_rhs&gt;
        in &lt;body&gt;

and suppose f is overloaded.

STEP 1: CALL-INSTANCE COLLECTION

We traverse &lt;body&gt;, accumulating all applications of f to types and
dictionaries.

(Might there be partial applications, to just some of its types and
dictionaries?  In principle yes, but in practice the type checker only
builds applications of f to all its types and dictionaries, so partial
applications could only arise as a result of transformation, and even
then I think it's unlikely.  In any case, we simply don't accumulate such
partial applications.)


STEP 2: EQUIVALENCES

So now we have a collection of calls to f:
        f t1 t2 d1 d2
        f t3 t4 d3 d4
        ...
Notice that f may take several type arguments.  To avoid ambiguity, we
say that f is called at type t1/t2 and t3/t4.

We take equivalence classes using equality of the *types* (ignoring
the dictionary args, which as mentioned previously are redundant).

STEP 3: SPECIALISATION

For each equivalence class, choose a representative (f t1 t2 d1 d2),
and create a local instance of f, defined thus:

        f@t1/t2 = &lt;f_rhs&gt; t1 t2 d1 d2

f_rhs presumably has some big lambdas and dictionary lambdas, so lots
of simplification will now result.  However we don't actually *do* that
simplification.  Rather, we leave it for the simplifier to do.  If we
*did* do it, though, we'd get more call instances from the specialised
RHS.  We can work out what they are by instantiating the call-instance
set from f's RHS with the types t1, t2.

Add this new id to f's IdInfo, to record that f has a specialised version.

Before doing any of this, check that f's IdInfo doesn't already
tell us about an existing instance of f at the required type/s.
(This might happen if specialisation was applied more than once, or
it might arise from user SPECIALIZE pragmas.)

Recursion
~~~~~~~~~
Wait a minute!  What if f is recursive?  Then we can't just plug in
its right-hand side, can we?

But it's ok.  The type checker *always* creates non-recursive definitions
for overloaded recursive functions.  For example:

        f x = f (x+x)           -- Yes I know its silly

becomes

        f a (d::Num a) = let p = +.sel a d
                         in
                         letrec fl (y::a) = fl (p y y)
                         in
                         fl

We still have recursion for non-overloaded functions which we
specialise, but the recursive call should get specialised to the
same recursive version.


Polymorphism 1
~~~~~~~~~~~~~~

All this is crystal clear when the function is applied to *constant
types*; that is, types which have no type variables inside.  But what if
it is applied to non-constant types?  Suppose we find a call of f at type
t1/t2.  There are two possibilities:

(a) The free type variables of t1, t2 are in scope at the definition point
of f.  In this case there's no problem, we proceed just as before.  A common
example is as follows.  Here's the Haskell:

        g y = let f x = x+x
              in f y + f y

After typechecking we have

        g a (d::Num a) (y::a) = let f b (d'::Num b) (x::b) = +.sel b d' x x
                                in +.sel a d (f a d y) (f a d y)

Notice that the call to f is at type type &quot;a&quot;; a non-constant type.
Both calls to f are at the same type, so we can specialise to give:

        g a (d::Num a) (y::a) = let f@a (x::a) = +.sel a d x x
                                in +.sel a d (f@a y) (f@a y)


(b) The other case is when the type variables in the instance types
are *not* in scope at the definition point of f.  The example we are
working with above is a good case.  There are two instances of (+.sel a d),
but &quot;a&quot; is not in scope at the definition of +.sel.  Can we do anything?
Yes, we can &quot;common them up&quot;, a sort of limited common sub-expression deal.
This would give:

        g a (d::Num a) (y::a) = let +.sel@a = +.sel a d
                                    f@a (x::a) = +.sel@a x x
                                in +.sel@a (f@a y) (f@a y)

This can save work, and can't be spotted by the type checker, because
the two instances of +.sel weren't originally at the same type.

Further notes on (b)

* There are quite a few variations here.  For example, the defn of
  +.sel could be floated outside the \y, to attempt to gain laziness.
  It certainly mustn't be floated outside the \d because the d has to
  be in scope too.

* We don't want to inline f_rhs in this case, because
that will duplicate code.  Just commoning up the call is the point.

* Nothing gets added to +.sel's IdInfo.

* Don't bother unless the equivalence class has more than one item!

Not clear whether this is all worth it.  It is of course OK to
simply discard call-instances when passing a big lambda.

Polymorphism 2 -- Overloading
~~~~~~~~~~~~~~
Consider a function whose most general type is

        f :: forall a b. Ord a =&gt; [a] -&gt; b -&gt; b

There is really no point in making a version of g at Int/Int and another
at Int/Bool, because it's only instantiating the type variable &quot;a&quot; which
buys us any efficiency. Since g is completely polymorphic in b there
ain't much point in making separate versions of g for the different
b types.

That suggests that we should identify which of g's type variables
are constrained (like &quot;a&quot;) and which are unconstrained (like &quot;b&quot;).
Then when taking equivalence classes in STEP 2, we ignore the type args
corresponding to unconstrained type variable.  In STEP 3 we make
polymorphic versions.  Thus:

        f@t1/ = /\b -&gt; &lt;f_rhs&gt; t1 b d1 d2

We do this.


Dictionary floating
~~~~~~~~~~~~~~~~~~~
Consider this

        f a (d::Num a) = let g = ...
                         in
                         ...(let d1::Ord a = Num.Ord.sel a d in g a d1)...

Here, g is only called at one type, but the dictionary isn't in scope at the
definition point for g.  Usually the type checker would build a
definition for d1 which enclosed g, but the transformation system
might have moved d1's defn inward.  Solution: float dictionary bindings
outwards along with call instances.

Consider

        f x = let g p q = p==q
                  h r s = (r+s, g r s)
              in
              h x x


Before specialisation, leaving out type abstractions we have

        f df x = let g :: Eq a =&gt; a -&gt; a -&gt; Bool
                     g dg p q = == dg p q
                     h :: Num a =&gt; a -&gt; a -&gt; (a, Bool)
                     h dh r s = let deq = eqFromNum dh
                                in (+ dh r s, g deq r s)
              in
              h df x x

After specialising h we get a specialised version of h, like this:

                    h' r s = let deq = eqFromNum df
                             in (+ df r s, g deq r s)

But we can't naively make an instance for g from this, because deq is not in scope
at the defn of g.  Instead, we have to float out the (new) defn of deq
to widen its scope.  Notice that this floating can't be done in advance -- it only
shows up when specialisation is done.

User SPECIALIZE pragmas
~~~~~~~~~~~~~~~~~~~~~~~
Specialisation pragmas can be digested by the type checker, and implemented
by adding extra definitions along with that of f, in the same way as before

        f@t1/t2 = &lt;f_rhs&gt; t1 t2 d1 d2

Indeed the pragmas *have* to be dealt with by the type checker, because
only it knows how to build the dictionaries d1 and d2!  For example

        g :: Ord a =&gt; [a] -&gt; [a]
        {-# SPECIALIZE f :: [Tree Int] -&gt; [Tree Int] #-}

Here, the specialised version of g is an application of g's rhs to the
Ord dictionary for (Tree Int), which only the type checker can conjure
up.  There might not even *be* one, if (Tree Int) is not an instance of
Ord!  (All the other specialision has suitable dictionaries to hand
from actual calls.)

Problem.  The type checker doesn't have to hand a convenient &lt;f_rhs&gt;, because
it is buried in a complex (as-yet-un-desugared) binding group.
Maybe we should say

        f@t1/t2 = f* t1 t2 d1 d2

where f* is the Id f with an IdInfo which says &quot;inline me regardless!&quot;.
Indeed all the specialisation could be done in this way.
That in turn means that the simplifier has to be prepared to inline absolutely
any in-scope let-bound thing.


Again, the pragma should permit polymorphism in unconstrained variables:

        h :: Ord a =&gt; [a] -&gt; b -&gt; b
        {-# SPECIALIZE h :: [Int] -&gt; b -&gt; b #-}

We *insist* that all overloaded type variables are specialised to ground types,
(and hence there can be no context inside a SPECIALIZE pragma).
We *permit* unconstrained type variables to be specialised to
        - a ground type
        - or left as a polymorphic type variable
but nothing in between.  So

        {-# SPECIALIZE h :: [Int] -&gt; [c] -&gt; [c] #-}

is *illegal*.  (It can be handled, but it adds complication, and gains the
programmer nothing.)


SPECIALISING INSTANCE DECLARATIONS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider

        instance Foo a =&gt; Foo [a] where
                ...
        {-# SPECIALIZE instance Foo [Int] #-}

The original instance decl creates a dictionary-function
definition:

        dfun.Foo.List :: forall a. Foo a -&gt; Foo [a]

The SPECIALIZE pragma just makes a specialised copy, just as for
ordinary function definitions:

        dfun.Foo.List@Int :: Foo [Int]
        dfun.Foo.List@Int = dfun.Foo.List Int dFooInt

The information about what instance of the dfun exist gets added to
the dfun's IdInfo in the same way as a user-defined function too.


Automatic instance decl specialisation?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Can instance decls be specialised automatically?  It's tricky.
We could collect call-instance information for each dfun, but
then when we specialised their bodies we'd get new call-instances
for ordinary functions; and when we specialised their bodies, we might get
new call-instances of the dfuns, and so on.  This all arises because of
the unrestricted mutual recursion between instance decls and value decls.

Still, there's no actual problem; it just means that we may not do all
the specialisation we could theoretically do.

Furthermore, instance decls are usually exported and used non-locally,
so we'll want to compile enough to get those specialisations done.

Lastly, there's no such thing as a local instance decl, so we can
survive solely by spitting out *usage* information, and then reading that
back in as a pragma when next compiling the file.  So for now,
we only specialise instance decls in response to pragmas.


SPITTING OUT USAGE INFORMATION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To spit out usage information we need to traverse the code collecting
call-instance information for all imported (non-prelude?) functions
and data types. Then we equivalence-class it and spit it out.

This is done at the top-level when all the call instances which escape
must be for imported functions and data types.

*** Not currently done ***


Partial specialisation by pragmas
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What about partial specialisation:

        k :: (Ord a, Eq b) =&gt; [a] -&gt; b -&gt; b -&gt; [a]
        {-# SPECIALIZE k :: Eq b =&gt; [Int] -&gt; b -&gt; b -&gt; [a] #-}

or even

        {-# SPECIALIZE k :: Eq b =&gt; [Int] -&gt; [b] -&gt; [b] -&gt; [a] #-}

Seems quite reasonable.  Similar things could be done with instance decls:

        instance (Foo a, Foo b) =&gt; Foo (a,b) where
                ...
        {-# SPECIALIZE instance Foo a =&gt; Foo (a,Int) #-}
        {-# SPECIALIZE instance Foo b =&gt; Foo (Int,b) #-}

Ho hum.  Things are complex enough without this.  I pass.


Requirements for the simplifier
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The simplifier has to be able to take advantage of the specialisation.

* When the simplifier finds an application of a polymorphic f, it looks in
f's IdInfo in case there is a suitable instance to call instead.  This converts

        f t1 t2 d1 d2   ===&gt;   f_t1_t2

Note that the dictionaries get eaten up too!

* Dictionary selection operations on constant dictionaries must be
  short-circuited:

        +.sel Int d     ===&gt;  +Int

The obvious way to do this is in the same way as other specialised
calls: +.sel has inside it some IdInfo which tells that if it's applied
to the type Int then it should eat a dictionary and transform to +Int.

In short, dictionary selectors need IdInfo inside them for constant
methods.

* Exactly the same applies if a superclass dictionary is being
  extracted:

        Eq.sel Int d   ===&gt;   dEqInt

* Something similar applies to dictionary construction too.  Suppose
dfun.Eq.List is the function taking a dictionary for (Eq a) to
one for (Eq [a]).  Then we want

        dfun.Eq.List Int d      ===&gt; dEq.List_Int

Where does the Eq [Int] dictionary come from?  It is built in
response to a SPECIALIZE pragma on the Eq [a] instance decl.

In short, dfun Ids need IdInfo with a specialisation for each
constant instance of their instance declaration.

All this uses a single mechanism: the SpecEnv inside an Id


What does the specialisation IdInfo look like?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The SpecEnv of an Id maps a list of types (the template) to an expression

        [Type]  |-&gt;  Expr

For example, if f has this RuleInfo:

        [Int, a]  -&gt;  \d:Ord Int. f' a

it means that we can replace the call

        f Int t  ===&gt;  (\d. f' t)

This chucks one dictionary away and proceeds with the
specialised version of f, namely f'.


What can't be done this way?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is no way, post-typechecker, to get a dictionary for (say)
Eq a from a dictionary for Eq [a].  So if we find

        ==.sel [t] d

we can't transform to

        eqList (==.sel t d')

where
        eqList :: (a-&gt;a-&gt;Bool) -&gt; [a] -&gt; [a] -&gt; Bool

Of course, we currently have no way to automatically derive
eqList, nor to connect it to the Eq [a] instance decl, but you
can imagine that it might somehow be possible.  Taking advantage
of this is permanently ruled out.

Still, this is no great hardship, because we intend to eliminate
overloading altogether anyway!

A note about non-tyvar dictionaries
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some Ids have types like

        forall a,b,c. Eq a -&gt; Ord [a] -&gt; tau

This seems curious at first, because we usually only have dictionary
args whose types are of the form (C a) where a is a type variable.
But this doesn't hold for the functions arising from instance decls,
which sometimes get arguments with types of form (C (T a)) for some
type constructor T.

Should we specialise wrt this compound-type dictionary?  We used to say
&quot;no&quot;, saying:
        &quot;This is a heuristic judgement, as indeed is the fact that we
        specialise wrt only dictionaries.  We choose *not* to specialise
        wrt compound dictionaries because at the moment the only place
        they show up is in instance decls, where they are simply plugged
        into a returned dictionary.  So nothing is gained by specialising
        wrt them.&quot;

But it is simpler and more uniform to specialise wrt these dicts too;
and in future GHC is likely to support full fledged type signatures
like
        f :: Eq [(a,b)] =&gt; ...


************************************************************************
*                                                                      *
\subsubsection{The new specialiser}
*                                                                      *
************************************************************************

Our basic game plan is this.  For let(rec) bound function
        f :: (C a, D c) =&gt; (a,b,c,d) -&gt; Bool

* Find any specialised calls of f, (f ts ds), where
  ts are the type arguments t1 .. t4, and
  ds are the dictionary arguments d1 .. d2.

* Add a new definition for f1 (say):

        f1 = /\ b d -&gt; (..body of f..) t1 b t3 d d1 d2

  Note that we abstract over the unconstrained type arguments.

* Add the mapping

        [t1,b,t3,d]  |-&gt;  \d1 d2 -&gt; f1 b d

  to the specialisations of f.  This will be used by the
  simplifier to replace calls
                (f t1 t2 t3 t4) da db
  by
                (\d1 d1 -&gt; f1 t2 t4) da db

  All the stuff about how many dictionaries to discard, and what types
  to apply the specialised function to, are handled by the fact that the
  SpecEnv contains a template for the result of the specialisation.

We don't build *partial* specialisations for f.  For example:

  f :: Eq a =&gt; a -&gt; a -&gt; Bool
  {-# SPECIALISE f :: (Eq b, Eq c) =&gt; (b,c) -&gt; (b,c) -&gt; Bool #-}

Here, little is gained by making a specialised copy of f.
There's a distinct danger that the specialised version would
first build a dictionary for (Eq b, Eq c), and then select the (==)
method from it!  Even if it didn't, not a great deal is saved.

We do, however, generate polymorphic, but not overloaded, specialisations:

  f :: Eq a =&gt; [a] -&gt; b -&gt; b -&gt; b
  ... SPECIALISE f :: [Int] -&gt; b -&gt; b -&gt; b ...

Hence, the invariant is this:

        *** no specialised version is overloaded ***


************************************************************************
*                                                                      *
\subsubsection{The exported function}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-583"></span><span>
</span><span id="line-584"></span><span class="hs-comment">-- | Specialise calls to type-class overloaded functions occurring in a program.</span><span>
</span><span id="line-585"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specProgram"><span class="hs-identifier hs-type">specProgram</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#ModGuts"><span class="hs-identifier hs-type">ModGuts</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#CoreM"><span class="hs-identifier hs-type">CoreM</span></a></span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#ModGuts"><span class="hs-identifier hs-type">ModGuts</span></a></span><span>
</span><span id="line-586"></span><span id="specProgram"><span class="annot"><span class="annottext">specProgram :: ModGuts -&gt; CoreM ModGuts
</span><a href="GHC.Core.Opt.Specialise.html#specProgram"><span class="hs-identifier hs-var hs-var">specProgram</span></a></span></span><span> </span><span id="local-6989586621680967416"><span class="annot"><span class="annottext">guts :: ModGuts
</span><a href="#local-6989586621680967416"><span class="hs-identifier hs-var">guts</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Types.html#ModGuts"><span class="hs-identifier hs-type">ModGuts</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mg_module :: ModGuts -&gt; Module
</span><a href="GHC.Driver.Types.html#mg_module"><span class="hs-identifier hs-var">mg_module</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967413"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967413"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span>
</span><span id="line-587"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_rules :: ModGuts -&gt; [CoreRule]
</span><a href="GHC.Driver.Types.html#mg_rules"><span class="hs-identifier hs-var">mg_rules</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967411"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967411"><span class="hs-identifier hs-var">local_rules</span></a></span></span><span>
</span><span id="line-588"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_binds :: ModGuts -&gt; CoreProgram
</span><a href="GHC.Driver.Types.html#mg_binds"><span class="hs-identifier hs-var">mg_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967409"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967409"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-589"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680967408"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967408"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreM DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-590"></span><span>
</span><span id="line-591"></span><span>             </span><span class="hs-comment">-- Specialise the bindings of this module</span><span>
</span><span id="line-592"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967406"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967406"><span class="hs-identifier hs-var">binds'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967405"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967405"><span class="hs-identifier hs-var">uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Module
-&gt; SpecM (CoreProgram, UsageDetails)
-&gt; CoreM (CoreProgram, UsageDetails)
forall a. DynFlags -&gt; Module -&gt; SpecM a -&gt; CoreM a
</span><a href="GHC.Core.Opt.Specialise.html#runSpecM"><span class="hs-identifier hs-var">runSpecM</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967408"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967413"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreProgram -&gt; SpecM (CoreProgram, UsageDetails)
</span><a href="#local-6989586621680967403"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967409"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-593"></span><span>
</span><span id="line-594"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967402"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967402"><span class="hs-identifier hs-var">spec_rules</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967401"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967401"><span class="hs-identifier hs-var">spec_binds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Module
-&gt; SpecEnv
-&gt; [CoreRule]
-&gt; UsageDetails
-&gt; CoreM ([CoreRule], CoreProgram)
</span><a href="GHC.Core.Opt.Specialise.html#specImports"><span class="hs-identifier hs-var">specImports</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967408"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967413"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967399"><span class="hs-identifier hs-var">top_env</span></a></span><span>
</span><span id="line-595"></span><span>                                                 </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967411"><span class="hs-identifier hs-var">local_rules</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967405"><span class="hs-identifier hs-var">uds</span></a></span><span>
</span><span id="line-596"></span><span>
</span><span id="line-597"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ModGuts -&gt; CoreM ModGuts
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModGuts
</span><a href="#local-6989586621680967416"><span class="hs-identifier hs-var">guts</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mg_binds :: CoreProgram
</span><a href="GHC.Driver.Types.html#mg_binds"><span class="hs-identifier hs-var">mg_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967401"><span class="hs-identifier hs-var">spec_binds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; CoreProgram -&gt; CoreProgram
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967406"><span class="hs-identifier hs-var">binds'</span></a></span><span>
</span><span id="line-598"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_rules :: [CoreRule]
</span><a href="GHC.Driver.Types.html#mg_rules"><span class="hs-identifier hs-var">mg_rules</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967402"><span class="hs-identifier hs-var">spec_rules</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule] -&gt; [CoreRule] -&gt; [CoreRule]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967411"><span class="hs-identifier hs-var">local_rules</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-599"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-600"></span><span>        </span><span class="hs-comment">-- We need to start with a Subst that knows all the things</span><span>
</span><span id="line-601"></span><span>        </span><span class="hs-comment">-- that are in scope, so that the substitution engine doesn't</span><span>
</span><span id="line-602"></span><span>        </span><span class="hs-comment">-- accidentally re-use a unique that's already in use</span><span>
</span><span id="line-603"></span><span>        </span><span class="hs-comment">-- Easiest thing is to do it all at once, as if all the top-level</span><span>
</span><span id="line-604"></span><span>        </span><span class="hs-comment">-- decls were mutually recursive</span><span>
</span><span id="line-605"></span><span>    </span><span id="local-6989586621680967399"><span class="annot"><span class="annottext">top_env :: SpecEnv
</span><a href="#local-6989586621680967399"><span class="hs-identifier hs-var hs-var">top_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SE :: Subst -&gt; VarSet -&gt; SpecEnv
</span><a href="GHC.Core.Opt.Specialise.html#SE"><span class="hs-identifier hs-type">SE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Subst
</span><a href="GHC.Core.Subst.html#mkEmptySubst"><span class="hs-identifier hs-var">Core.mkEmptySubst</span></a></span><span> </span><span class="annot"><span class="annottext">(InScopeSet -&gt; Subst) -&gt; InScopeSet -&gt; Subst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; InScopeSet) -&gt; VarSet -&gt; InScopeSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">([Id] -&gt; VarSet) -&gt; [Id] -&gt; VarSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-606"></span><span>                              </span><span class="annot"><span class="annottext">CoreProgram -&gt; [Id]
forall b. [Bind b] -&gt; [b]
</span><a href="GHC.Core.html#bindersOfBinds"><span class="hs-identifier hs-var">bindersOfBinds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967409"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-607"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">se_interesting :: VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var">se_interesting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-608"></span><span>
</span><span id="line-609"></span><span>    </span><span id="local-6989586621680967403"><span class="annot"><span class="annottext">go :: CoreProgram -&gt; SpecM (CoreProgram, UsageDetails)
</span><a href="#local-6989586621680967403"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreProgram, UsageDetails) -&gt; SpecM (CoreProgram, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var">emptyUDs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-610"></span><span>    </span><span class="annot"><a href="#local-6989586621680967403"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967385"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680967385"><span class="hs-identifier hs-var">bind</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680967384"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967384"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967383"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967383"><span class="hs-identifier hs-var">binds'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967382"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967382"><span class="hs-identifier hs-var">uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; SpecM (CoreProgram, UsageDetails)
</span><a href="#local-6989586621680967403"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967384"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-611"></span><span>                         </span><span class="hs-special">(</span><span id="local-6989586621680967381"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967381"><span class="hs-identifier hs-var">bind'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967380"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967380"><span class="hs-identifier hs-var">uds'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; CoreBind -&gt; UsageDetails -&gt; SpecM (CoreProgram, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specBind"><span class="hs-identifier hs-var">specBind</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967399"><span class="hs-identifier hs-var">top_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680967385"><span class="hs-identifier hs-var">bind</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967382"><span class="hs-identifier hs-var">uds</span></a></span><span>
</span><span id="line-612"></span><span>                         </span><span class="annot"><span class="annottext">(CoreProgram, UsageDetails) -&gt; SpecM (CoreProgram, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967381"><span class="hs-identifier hs-var">bind'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; CoreProgram -&gt; CoreProgram
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967383"><span class="hs-identifier hs-var">binds'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967380"><span class="hs-identifier hs-var">uds'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-613"></span><span>
</span><span id="line-614"></span><span class="hs-comment">{-
Note [Wrap bindings returned by specImports]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'specImports' returns a set of specialized bindings. However, these are lacking
necessary floated dictionary bindings, which are returned by
UsageDetails(ud_binds). These dictionaries need to be brought into scope with
'wrapDictBinds' before the bindings returned by 'specImports' can be used. See,
for instance, the 'specImports' call in 'specProgram'.


Note [Disabling cross-module specialisation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since GHC 7.10 we have performed specialisation of INLINABLE bindings living
in modules outside of the current module. This can sometimes uncover user code
which explodes in size when aggressively optimized. The
-fno-cross-module-specialise option was introduced to allow users to being
bitten by such instances to revert to the pre-7.10 behavior.

See #10491
-}</span><span>
</span><span id="line-634"></span><span>
</span><span id="line-635"></span><span>
</span><span id="line-636"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
                   Specialising imported functions
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-641"></span><span>
</span><span id="line-642"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specImports"><span class="hs-identifier hs-type">specImports</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier hs-type">Module</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>
</span><span id="line-643"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-644"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-645"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#CoreM"><span class="hs-identifier hs-type">CoreM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-646"></span><span id="specImports"><span class="annot"><span class="annottext">specImports :: DynFlags
-&gt; Module
-&gt; SpecEnv
-&gt; [CoreRule]
-&gt; UsageDetails
-&gt; CoreM ([CoreRule], CoreProgram)
</span><a href="GHC.Core.Opt.Specialise.html#specImports"><span class="hs-identifier hs-var hs-var">specImports</span></a></span></span><span> </span><span id="local-6989586621680967378"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967378"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680967377"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967377"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span id="local-6989586621680967376"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967376"><span class="hs-identifier hs-var">top_env</span></a></span></span><span> </span><span id="local-6989586621680967375"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967375"><span class="hs-identifier hs-var">local_rules</span></a></span></span><span>
</span><span id="line-647"></span><span>            </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967372"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967372"><span class="hs-identifier hs-var">dict_binds</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: UsageDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967370"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680967370"><span class="hs-identifier hs-var">calls</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-648"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_CrossModuleSpecialise"><span class="hs-identifier hs-var">Opt_CrossModuleSpecialise</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967378"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-649"></span><span>    </span><span class="hs-comment">-- See Note [Disabling cross-module specialisation]</span><span>
</span><span id="line-650"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([CoreRule], CoreProgram) -&gt; CoreM ([CoreRule], CoreProgram)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; CoreProgram -&gt; CoreProgram
</span><a href="GHC.Core.Opt.Specialise.html#wrapDictBinds"><span class="hs-identifier hs-var">wrapDictBinds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967372"><span class="hs-identifier hs-var">dict_binds</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-651"></span><span>
</span><span id="line-652"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-653"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680967365"><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967365"><span class="hs-identifier hs-var">hpt_rules</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreM RuleBase
</span><a href="GHC.Core.Opt.Monad.html#getRuleBase"><span class="hs-identifier hs-var">getRuleBase</span></a></span><span>
</span><span id="line-654"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680967363"><span class="annot"><span class="annottext">rule_base :: RuleBase
</span><a href="#local-6989586621680967363"><span class="hs-identifier hs-var hs-var">rule_base</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RuleBase -&gt; [CoreRule] -&gt; RuleBase
</span><a href="GHC.Core.Rules.html#extendRuleBaseList"><span class="hs-identifier hs-var">extendRuleBaseList</span></a></span><span> </span><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967365"><span class="hs-identifier hs-var">hpt_rules</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967375"><span class="hs-identifier hs-var">local_rules</span></a></span><span>
</span><span id="line-655"></span><span>
</span><span id="line-656"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967361"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967361"><span class="hs-identifier hs-var">spec_rules</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967360"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967360"><span class="hs-identifier hs-var">spec_binds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Module
-&gt; SpecEnv
-&gt; [Id]
-&gt; RuleBase
-&gt; Bag DictBind
-&gt; CallDetails
-&gt; CoreM ([CoreRule], CoreProgram)
</span><a href="GHC.Core.Opt.Specialise.html#spec_imports"><span class="hs-identifier hs-var">spec_imports</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967378"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967377"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967376"><span class="hs-identifier hs-var">top_env</span></a></span><span>
</span><span id="line-657"></span><span>                                                  </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967363"><span class="hs-identifier hs-var">rule_base</span></a></span><span>
</span><span id="line-658"></span><span>                                                  </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967372"><span class="hs-identifier hs-var">dict_binds</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680967370"><span class="hs-identifier hs-var">calls</span></a></span><span>
</span><span id="line-659"></span><span>
</span><span id="line-660"></span><span>             </span><span class="hs-comment">-- Don't forget to wrap the specialized bindings with</span><span>
</span><span id="line-661"></span><span>             </span><span class="hs-comment">-- bindings for the needed dictionaries.</span><span>
</span><span id="line-662"></span><span>             </span><span class="hs-comment">-- See Note [Wrap bindings returned by specImports]</span><span>
</span><span id="line-663"></span><span>             </span><span class="hs-comment">-- and Note [Glom the bindings if imported functions are specialised]</span><span>
</span><span id="line-664"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680967357"><span class="annot"><span class="annottext">final_binds :: CoreProgram
</span><a href="#local-6989586621680967357"><span class="hs-identifier hs-var hs-var">final_binds</span></a></span></span><span>
</span><span id="line-665"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967360"><span class="hs-identifier hs-var">spec_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; CoreProgram -&gt; CoreProgram
</span><a href="GHC.Core.Opt.Specialise.html#wrapDictBinds"><span class="hs-identifier hs-var">wrapDictBinds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967372"><span class="hs-identifier hs-var">dict_binds</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-666"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="annot"><span class="annottext">([(Id, CoreExpr)] -&gt; CoreBind) -&gt; [(Id, CoreExpr)] -&gt; CoreBind
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; [(Id, CoreExpr)]
forall b. [Bind b] -&gt; [(b, Expr b)]
</span><a href="GHC.Core.html#flattenBinds"><span class="hs-identifier hs-var">flattenBinds</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreProgram -&gt; [(Id, CoreExpr)])
-&gt; CoreProgram -&gt; [(Id, CoreExpr)]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-667"></span><span>                                    </span><span class="annot"><span class="annottext">Bag DictBind -&gt; CoreProgram -&gt; CoreProgram
</span><a href="GHC.Core.Opt.Specialise.html#wrapDictBinds"><span class="hs-identifier hs-var">wrapDictBinds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967372"><span class="hs-identifier hs-var">dict_binds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967360"><span class="hs-identifier hs-var">spec_binds</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-668"></span><span>
</span><span id="line-669"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([CoreRule], CoreProgram) -&gt; CoreM ([CoreRule], CoreProgram)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967361"><span class="hs-identifier hs-var">spec_rules</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967357"><span class="hs-identifier hs-var">final_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-670"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-671"></span><span>
</span><span id="line-672"></span><span class="hs-comment">-- | Specialise a set of calls to imported bindings</span><span>
</span><span id="line-673"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#spec_imports"><span class="hs-identifier hs-type">spec_imports</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-674"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier hs-type">Module</span></a></span><span>
</span><span id="line-675"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>          </span><span class="hs-comment">-- Passed in so that all top-level Ids are in scope</span><span>
</span><span id="line-676"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>             </span><span class="hs-comment">-- Stack of imported functions being specialised</span><span>
</span><span id="line-677"></span><span>                                 </span><span class="hs-comment">-- See Note [specImport call stack]</span><span>
</span><span id="line-678"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#RuleBase"><span class="hs-identifier hs-type">RuleBase</span></a></span><span>         </span><span class="hs-comment">-- Rules from this module and the home package</span><span>
</span><span id="line-679"></span><span>                                 </span><span class="hs-comment">-- (but not external packages, which can change)</span><span>
</span><span id="line-680"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span>     </span><span class="hs-comment">-- Dict bindings, used /only/ for filterCalls</span><span>
</span><span id="line-681"></span><span>                                 </span><span class="hs-comment">-- See Note [Avoiding loops in specImports]</span><span>
</span><span id="line-682"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-type">CallDetails</span></a></span><span>      </span><span class="hs-comment">-- Calls for imported things</span><span>
</span><span id="line-683"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#CoreM"><span class="hs-identifier hs-type">CoreM</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- New rules</span><span>
</span><span id="line-684"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Specialised bindings</span><span>
</span><span id="line-685"></span><span id="spec_imports"><span class="annot"><span class="annottext">spec_imports :: DynFlags
-&gt; Module
-&gt; SpecEnv
-&gt; [Id]
-&gt; RuleBase
-&gt; Bag DictBind
-&gt; CallDetails
-&gt; CoreM ([CoreRule], CoreProgram)
</span><a href="GHC.Core.Opt.Specialise.html#spec_imports"><span class="hs-identifier hs-var hs-var">spec_imports</span></a></span></span><span> </span><span id="local-6989586621680967353"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967353"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680967352"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967352"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span id="local-6989586621680967351"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967351"><span class="hs-identifier hs-var">top_env</span></a></span></span><span>
</span><span id="line-686"></span><span>             </span><span id="local-6989586621680967350"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967350"><span class="hs-identifier hs-var">callers</span></a></span></span><span> </span><span id="local-6989586621680967349"><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967349"><span class="hs-identifier hs-var">rule_base</span></a></span></span><span> </span><span id="local-6989586621680967348"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967348"><span class="hs-identifier hs-var">dict_binds</span></a></span></span><span> </span><span id="local-6989586621680967347"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680967347"><span class="hs-identifier hs-var">calls</span></a></span></span><span>
</span><span id="line-687"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680967346"><span class="annot"><span class="annottext">import_calls :: [CallInfoSet]
</span><a href="#local-6989586621680967346"><span class="hs-identifier hs-var hs-var">import_calls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallDetails -&gt; [CallInfoSet]
forall a. DVarEnv a -&gt; [a]
</span><a href="GHC.Types.Var.Env.html#dVarEnvElts"><span class="hs-identifier hs-var">dVarEnvElts</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680967347"><span class="hs-identifier hs-var">calls</span></a></span><span>
</span><span id="line-688"></span><span>       </span><span class="hs-comment">-- ; debugTraceMsg (text &quot;specImports {&quot; &lt;+&gt;</span><span>
</span><span id="line-689"></span><span>       </span><span class="hs-comment">--                  vcat [ text &quot;calls:&quot; &lt;+&gt; ppr import_calls</span><span>
</span><span id="line-690"></span><span>       </span><span class="hs-comment">--                       , text &quot;dict_binds:&quot; &lt;+&gt; ppr dict_binds ])</span><span>
</span><span id="line-691"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967344"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967344"><span class="hs-identifier hs-var">rules</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967343"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967343"><span class="hs-identifier hs-var">spec_binds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RuleBase -&gt; [CallInfoSet] -&gt; CoreM ([CoreRule], CoreProgram)
</span><a href="#local-6989586621680967342"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967349"><span class="hs-identifier hs-var">rule_base</span></a></span><span> </span><span class="annot"><span class="annottext">[CallInfoSet]
</span><a href="#local-6989586621680967346"><span class="hs-identifier hs-var">import_calls</span></a></span><span>
</span><span id="line-692"></span><span>       </span><span class="hs-comment">-- ; debugTraceMsg (text &quot;End specImports }&quot; &lt;+&gt; ppr import_calls)</span><span>
</span><span id="line-693"></span><span>
</span><span id="line-694"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([CoreRule], CoreProgram) -&gt; CoreM ([CoreRule], CoreProgram)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967344"><span class="hs-identifier hs-var">rules</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967343"><span class="hs-identifier hs-var">spec_binds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-695"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-696"></span><span>    </span><span class="annot"><a href="#local-6989586621680967342"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#RuleBase"><span class="hs-identifier hs-type">RuleBase</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#CoreM"><span class="hs-identifier hs-type">CoreM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-697"></span><span>    </span><span id="local-6989586621680967342"><span class="annot"><span class="annottext">go :: RuleBase -&gt; [CallInfoSet] -&gt; CoreM ([CoreRule], CoreProgram)
</span><a href="#local-6989586621680967342"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">RuleBase
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([CoreRule], CoreProgram) -&gt; CoreM ([CoreRule], CoreProgram)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-698"></span><span>    </span><span class="annot"><a href="#local-6989586621680967342"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680967341"><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967341"><span class="hs-identifier hs-var">rb</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967340"><span class="annot"><span class="annottext">CallInfoSet
</span><a href="#local-6989586621680967340"><span class="hs-identifier hs-var">cis</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680967339"><span class="annot"><span class="annottext">[CallInfoSet]
</span><a href="#local-6989586621680967339"><span class="hs-identifier hs-var">other_calls</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-699"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- debugTraceMsg (text &quot;specImport {&quot; &lt;+&gt; ppr cis)</span><span>
</span><span id="line-700"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967338"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967338"><span class="hs-identifier hs-var">rules1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967337"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967337"><span class="hs-identifier hs-var">spec_binds1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Module
-&gt; SpecEnv
-&gt; [Id]
-&gt; RuleBase
-&gt; Bag DictBind
-&gt; CallInfoSet
-&gt; CoreM ([CoreRule], CoreProgram)
</span><a href="GHC.Core.Opt.Specialise.html#spec_import"><span class="hs-identifier hs-var">spec_import</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967353"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967352"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967351"><span class="hs-identifier hs-var">top_env</span></a></span><span>
</span><span id="line-701"></span><span>                                                  </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967350"><span class="hs-identifier hs-var">callers</span></a></span><span> </span><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967341"><span class="hs-identifier hs-var">rb</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967348"><span class="hs-identifier hs-var">dict_binds</span></a></span><span> </span><span class="annot"><span class="annottext">CallInfoSet
</span><a href="#local-6989586621680967340"><span class="hs-identifier hs-var">cis</span></a></span><span>
</span><span id="line-702"></span><span>           </span><span class="hs-comment">-- ; debugTraceMsg (text &quot;specImport }&quot; &lt;+&gt; ppr cis)</span><span>
</span><span id="line-703"></span><span>
</span><span id="line-704"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967335"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967335"><span class="hs-identifier hs-var">rules2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967334"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967334"><span class="hs-identifier hs-var">spec_binds2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RuleBase -&gt; [CallInfoSet] -&gt; CoreM ([CoreRule], CoreProgram)
</span><a href="#local-6989586621680967342"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RuleBase -&gt; [CoreRule] -&gt; RuleBase
</span><a href="GHC.Core.Rules.html#extendRuleBaseList"><span class="hs-identifier hs-var">extendRuleBaseList</span></a></span><span> </span><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967341"><span class="hs-identifier hs-var">rb</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967338"><span class="hs-identifier hs-var">rules1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CallInfoSet]
</span><a href="#local-6989586621680967339"><span class="hs-identifier hs-var">other_calls</span></a></span><span>
</span><span id="line-705"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([CoreRule], CoreProgram) -&gt; CoreM ([CoreRule], CoreProgram)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967338"><span class="hs-identifier hs-var">rules1</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule] -&gt; [CoreRule] -&gt; [CoreRule]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967335"><span class="hs-identifier hs-var">rules2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967337"><span class="hs-identifier hs-var">spec_binds1</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; CoreProgram -&gt; CoreProgram
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967334"><span class="hs-identifier hs-var">spec_binds2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-706"></span><span>
</span><span id="line-707"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#spec_import"><span class="hs-identifier hs-type">spec_import</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-708"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier hs-type">Module</span></a></span><span>
</span><span id="line-709"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>               </span><span class="hs-comment">-- Passed in so that all top-level Ids are in scope</span><span>
</span><span id="line-710"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>                  </span><span class="hs-comment">-- Stack of imported functions being specialised</span><span>
</span><span id="line-711"></span><span>                                     </span><span class="hs-comment">-- See Note [specImport call stack]</span><span>
</span><span id="line-712"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#RuleBase"><span class="hs-identifier hs-type">RuleBase</span></a></span><span>              </span><span class="hs-comment">-- Rules from this module</span><span>
</span><span id="line-713"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span>          </span><span class="hs-comment">-- Dict bindings, used /only/ for filterCalls</span><span>
</span><span id="line-714"></span><span>                                     </span><span class="hs-comment">-- See Note [Avoiding loops in specImports]</span><span>
</span><span id="line-715"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span><span>           </span><span class="hs-comment">-- Imported function and calls for it</span><span>
</span><span id="line-716"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#CoreM"><span class="hs-identifier hs-type">CoreM</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- New rules</span><span>
</span><span id="line-717"></span><span>                     </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Specialised bindings</span><span>
</span><span id="line-718"></span><span id="spec_import"><span class="annot"><span class="annottext">spec_import :: DynFlags
-&gt; Module
-&gt; SpecEnv
-&gt; [Id]
-&gt; RuleBase
-&gt; Bag DictBind
-&gt; CallInfoSet
-&gt; CoreM ([CoreRule], CoreProgram)
</span><a href="GHC.Core.Opt.Specialise.html#spec_import"><span class="hs-identifier hs-var hs-var">spec_import</span></a></span></span><span> </span><span id="local-6989586621680967333"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967333"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680967332"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967332"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span id="local-6989586621680967331"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967331"><span class="hs-identifier hs-var">top_env</span></a></span></span><span> </span><span id="local-6989586621680967330"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967330"><span class="hs-identifier hs-var">callers</span></a></span></span><span>
</span><span id="line-719"></span><span>            </span><span id="local-6989586621680967329"><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967329"><span class="hs-identifier hs-var">rb</span></a></span></span><span> </span><span id="local-6989586621680967328"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967328"><span class="hs-identifier hs-var">dict_binds</span></a></span></span><span> </span><span id="local-6989586621680967327"><span class="annot"><span class="annottext">cis :: CallInfoSet
</span><a href="#local-6989586621680967327"><span class="hs-identifier hs-var">cis</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-type">CIS</span></a></span><span> </span><span id="local-6989586621680967325"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967325"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bag CallInfo
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-720"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">String -&gt; Id -&gt; [Id] -&gt; Bool
forall a. Eq a =&gt; String -&gt; a -&gt; [a] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#isIn"><span class="hs-identifier hs-var">isIn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;specImport&quot;</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967325"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967330"><span class="hs-identifier hs-var">callers</span></a></span><span>
</span><span id="line-721"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([CoreRule], CoreProgram) -&gt; CoreM ([CoreRule], CoreProgram)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>     </span><span class="hs-comment">-- No warning.  This actually happens all the time</span><span>
</span><span id="line-722"></span><span>                        </span><span class="hs-comment">-- when specialising a recursive function, because</span><span>
</span><span id="line-723"></span><span>                        </span><span class="hs-comment">-- the RHS of the specialised function contains a recursive</span><span>
</span><span id="line-724"></span><span>                        </span><span class="hs-comment">-- call to the original function</span><span>
</span><span id="line-725"></span><span>
</span><span id="line-726"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[CallInfo] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680967323"><span class="hs-identifier hs-var">good_calls</span></a></span><span>
</span><span id="line-727"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- debugTraceMsg (text &quot;specImport:no valid calls&quot;)</span><span>
</span><span id="line-728"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([CoreRule], CoreProgram) -&gt; CoreM ([CoreRule], CoreProgram)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-729"></span><span>
</span><span id="line-730"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Unfolding -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#wantSpecImport"><span class="hs-identifier hs-var">wantSpecImport</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967333"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680967321"><span class="hs-identifier hs-var">unfolding</span></a></span><span>
</span><span id="line-731"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680967320"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967320"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; Maybe CoreExpr
</span><a href="GHC.Core.html#maybeUnfoldingTemplate"><span class="hs-identifier hs-var">maybeUnfoldingTemplate</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680967321"><span class="hs-identifier hs-var">unfolding</span></a></span><span>
</span><span id="line-732"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>     </span><span class="hs-comment">-- Get rules from the external package state</span><span>
</span><span id="line-733"></span><span>             </span><span class="hs-comment">-- We keep doing this in case we &quot;page-fault in&quot;</span><span>
</span><span id="line-734"></span><span>             </span><span class="hs-comment">-- more rules as we go along</span><span>
</span><span id="line-735"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680967318"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621680967318"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreM HscEnv
</span><a href="GHC.Core.Opt.Monad.html#getHscEnv"><span class="hs-identifier hs-var">getHscEnv</span></a></span><span>
</span><span id="line-736"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680967316"><span class="annot"><span class="annottext">ExternalPackageState
</span><a href="#local-6989586621680967316"><span class="hs-identifier hs-var">eps</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO ExternalPackageState -&gt; CoreM ExternalPackageState
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO ExternalPackageState -&gt; CoreM ExternalPackageState)
-&gt; IO ExternalPackageState -&gt; CoreM ExternalPackageState
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; IO ExternalPackageState
</span><a href="GHC.Driver.Types.html#hscEPS"><span class="hs-identifier hs-var">hscEPS</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621680967318"><span class="hs-identifier hs-var">hsc_env</span></a></span><span>
</span><span id="line-737"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680967313"><span class="annot"><span class="annottext">ModuleSet
</span><a href="#local-6989586621680967313"><span class="hs-identifier hs-var">vis_orphs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreM ModuleSet
</span><a href="GHC.Core.Opt.Monad.html#getVisibleOrphanMods"><span class="hs-identifier hs-var">getVisibleOrphanMods</span></a></span><span>
</span><span id="line-738"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680967311"><span class="annot"><span class="annottext">full_rb :: RuleBase
</span><a href="#local-6989586621680967311"><span class="hs-identifier hs-var hs-var">full_rb</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RuleBase -&gt; RuleBase -&gt; RuleBase
</span><a href="GHC.Core.Rules.html#unionRuleBase"><span class="hs-identifier hs-var">unionRuleBase</span></a></span><span> </span><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967329"><span class="hs-identifier hs-var">rb</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ExternalPackageState -&gt; RuleBase
</span><a href="GHC.Driver.Types.html#eps_rule_base"><span class="hs-identifier hs-var hs-var">eps_rule_base</span></a></span><span> </span><span class="annot"><span class="annottext">ExternalPackageState
</span><a href="#local-6989586621680967316"><span class="hs-identifier hs-var">eps</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-739"></span><span>             </span><span id="local-6989586621680967308"><span class="annot"><span class="annottext">rules_for_fn :: [CoreRule]
</span><a href="#local-6989586621680967308"><span class="hs-identifier hs-var hs-var">rules_for_fn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RuleEnv -&gt; Id -&gt; [CoreRule]
</span><a href="GHC.Core.Rules.html#getRules"><span class="hs-identifier hs-var">getRules</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RuleBase -&gt; ModuleSet -&gt; RuleEnv
</span><a href="GHC.Core.html#RuleEnv"><span class="hs-identifier hs-var">RuleEnv</span></a></span><span> </span><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967311"><span class="hs-identifier hs-var">full_rb</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleSet
</span><a href="#local-6989586621680967313"><span class="hs-identifier hs-var">vis_orphs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967325"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-740"></span><span>
</span><span id="line-741"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967305"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967305"><span class="hs-identifier hs-var">rules1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967304"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680967304"><span class="hs-identifier hs-var">spec_pairs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967303"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967303"><span class="hs-identifier hs-var">dict_binds1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: UsageDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967302"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680967302"><span class="hs-identifier hs-var">new_calls</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-742"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- debugTraceMsg (text &quot;specImport1&quot; &lt;+&gt; vcat [ppr fn, ppr good_calls, ppr rhs])</span><span>
</span><span id="line-743"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Module
-&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
-&gt; CoreM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
forall a. DynFlags -&gt; Module -&gt; SpecM a -&gt; CoreM a
</span><a href="GHC.Core.Opt.Specialise.html#runSpecM"><span class="hs-identifier hs-var">runSpecM</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967333"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967332"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">(SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
 -&gt; CoreM ([CoreRule], [(Id, CoreExpr)], UsageDetails))
-&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
-&gt; CoreM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-744"></span><span>                     </span><span class="annot"><span class="annottext">Maybe Module
-&gt; SpecEnv
-&gt; [CoreRule]
-&gt; [CallInfo]
-&gt; Id
-&gt; CoreExpr
-&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specCalls"><span class="hs-identifier hs-var">specCalls</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module -&gt; Maybe Module
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967332"><span class="hs-identifier hs-var">this_mod</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967331"><span class="hs-identifier hs-var">top_env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967308"><span class="hs-identifier hs-var">rules_for_fn</span></a></span><span> </span><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680967323"><span class="hs-identifier hs-var">good_calls</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967325"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967320"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-745"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680967300"><span class="annot"><span class="annottext">spec_binds1 :: CoreProgram
</span><a href="#local-6989586621680967300"><span class="hs-identifier hs-var hs-var">spec_binds1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967298"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967297"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967298"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967298"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680967297"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967297"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680967304"><span class="hs-identifier hs-var">spec_pairs</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-746"></span><span>             </span><span class="hs-comment">-- After the rules kick in we may get recursion, but</span><span>
</span><span id="line-747"></span><span>             </span><span class="hs-comment">-- we rely on a global GlomBinds to sort that out later</span><span>
</span><span id="line-748"></span><span>             </span><span class="hs-comment">-- See Note [Glom the bindings if imported functions are specialised]</span><span>
</span><span id="line-749"></span><span>
</span><span id="line-750"></span><span>              </span><span class="hs-comment">-- Now specialise any cascaded calls</span><span>
</span><span id="line-751"></span><span>       </span><span class="hs-comment">-- ; debugTraceMsg (text &quot;specImport 2&quot; &lt;+&gt; (ppr fn $$ ppr rules1 $$ ppr spec_binds1))</span><span>
</span><span id="line-752"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967296"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967296"><span class="hs-identifier hs-var">rules2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967295"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967295"><span class="hs-identifier hs-var">spec_binds2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Module
-&gt; SpecEnv
-&gt; [Id]
-&gt; RuleBase
-&gt; Bag DictBind
-&gt; CallDetails
-&gt; CoreM ([CoreRule], CoreProgram)
</span><a href="GHC.Core.Opt.Specialise.html#spec_imports"><span class="hs-identifier hs-var">spec_imports</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967333"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680967332"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967331"><span class="hs-identifier hs-var">top_env</span></a></span><span>
</span><span id="line-753"></span><span>                                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967325"><span class="hs-identifier hs-var">fn</span></a></span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967330"><span class="hs-identifier hs-var">callers</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-754"></span><span>                                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RuleBase -&gt; [CoreRule] -&gt; RuleBase
</span><a href="GHC.Core.Rules.html#extendRuleBaseList"><span class="hs-identifier hs-var">extendRuleBaseList</span></a></span><span> </span><span class="annot"><span class="annottext">RuleBase
</span><a href="#local-6989586621680967329"><span class="hs-identifier hs-var">rb</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967305"><span class="hs-identifier hs-var">rules1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-755"></span><span>                                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967328"><span class="hs-identifier hs-var">dict_binds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; Bag DictBind -&gt; Bag DictBind
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967303"><span class="hs-identifier hs-var">dict_binds1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-756"></span><span>                                               </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680967302"><span class="hs-identifier hs-var">new_calls</span></a></span><span>
</span><span id="line-757"></span><span>
</span><span id="line-758"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680967293"><span class="annot"><span class="annottext">final_binds :: CoreProgram
</span><a href="#local-6989586621680967293"><span class="hs-identifier hs-var hs-var">final_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; CoreProgram -&gt; CoreProgram
</span><a href="GHC.Core.Opt.Specialise.html#wrapDictBinds"><span class="hs-identifier hs-var">wrapDictBinds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967303"><span class="hs-identifier hs-var">dict_binds1</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreProgram -&gt; CoreProgram) -&gt; CoreProgram -&gt; CoreProgram
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-759"></span><span>                           </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967295"><span class="hs-identifier hs-var">spec_binds2</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; CoreProgram -&gt; CoreProgram
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967300"><span class="hs-identifier hs-var">spec_binds1</span></a></span><span>
</span><span id="line-760"></span><span>
</span><span id="line-761"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([CoreRule], CoreProgram) -&gt; CoreM ([CoreRule], CoreProgram)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967296"><span class="hs-identifier hs-var">rules2</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule] -&gt; [CoreRule] -&gt; [CoreRule]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680967305"><span class="hs-identifier hs-var">rules1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967293"><span class="hs-identifier hs-var">final_binds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-762"></span><span>
</span><span id="line-763"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-764"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [Id] -&gt; Id -&gt; [CallInfo] -&gt; CoreM ()
</span><a href="GHC.Core.Opt.Specialise.html#tryWarnMissingSpecs"><span class="hs-identifier hs-var">tryWarnMissingSpecs</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967333"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967330"><span class="hs-identifier hs-var">callers</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967325"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680967323"><span class="hs-identifier hs-var">good_calls</span></a></span><span>
</span><span id="line-765"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([CoreRule], CoreProgram) -&gt; CoreM ([CoreRule], CoreProgram)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">}</span><span>
</span><span id="line-766"></span><span>
</span><span id="line-767"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-768"></span><span>    </span><span id="local-6989586621680967321"><span class="annot"><span class="annottext">unfolding :: Unfolding
</span><a href="#local-6989586621680967321"><span class="hs-identifier hs-var hs-var">unfolding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Unfolding
</span><a href="GHC.Types.Id.html#realIdUnfolding"><span class="hs-identifier hs-var">realIdUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967325"><span class="hs-identifier hs-var">fn</span></a></span><span>   </span><span class="hs-comment">-- We want to see the unfolding even for loop breakers</span><span>
</span><span id="line-769"></span><span>    </span><span id="local-6989586621680967323"><span class="annot"><span class="annottext">good_calls :: [CallInfo]
</span><a href="#local-6989586621680967323"><span class="hs-identifier hs-var hs-var">good_calls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallInfoSet -&gt; Bag DictBind -&gt; [CallInfo]
</span><a href="GHC.Core.Opt.Specialise.html#filterCalls"><span class="hs-identifier hs-var">filterCalls</span></a></span><span> </span><span class="annot"><span class="annottext">CallInfoSet
</span><a href="#local-6989586621680967327"><span class="hs-identifier hs-var">cis</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967328"><span class="hs-identifier hs-var">dict_binds</span></a></span><span>
</span><span id="line-770"></span><span>       </span><span class="hs-comment">-- SUPER IMPORTANT!  Drop calls that (directly or indirectly) refer to fn</span><span>
</span><span id="line-771"></span><span>       </span><span class="hs-comment">-- See Note [Avoiding loops in specImports]</span><span>
</span><span id="line-772"></span><span>
</span><span id="line-773"></span><span class="hs-comment">-- | Returns whether or not to show a missed-spec warning.</span><span>
</span><span id="line-774"></span><span class="hs-comment">-- If -Wall-missed-specializations is on, show the warning.</span><span>
</span><span id="line-775"></span><span class="hs-comment">-- Otherwise, if -Wmissed-specializations is on, only show a warning</span><span>
</span><span id="line-776"></span><span class="hs-comment">-- if there is at least one imported function being specialized,</span><span>
</span><span id="line-777"></span><span class="hs-comment">-- and if all imported functions are marked with an inline pragma</span><span>
</span><span id="line-778"></span><span class="hs-comment">-- Use the most specific warning as the reason.</span><span>
</span><span id="line-779"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#tryWarnMissingSpecs"><span class="hs-identifier hs-type">tryWarnMissingSpecs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfo"><span class="hs-identifier hs-type">CallInfo</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#CoreM"><span class="hs-identifier hs-type">CoreM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-780"></span><span class="hs-comment">-- See Note [Warning about missed specialisations]</span><span>
</span><span id="line-781"></span><span id="tryWarnMissingSpecs"><span class="annot"><span class="annottext">tryWarnMissingSpecs :: DynFlags -&gt; [Id] -&gt; Id -&gt; [CallInfo] -&gt; CoreM ()
</span><a href="GHC.Core.Opt.Specialise.html#tryWarnMissingSpecs"><span class="hs-identifier hs-var hs-var">tryWarnMissingSpecs</span></a></span></span><span> </span><span id="local-6989586621680967289"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967289"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680967288"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967288"><span class="hs-identifier hs-var">callers</span></a></span></span><span> </span><span id="local-6989586621680967287"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967287"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621680967286"><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680967286"><span class="hs-identifier hs-var">calls_for_fn</span></a></span></span><span>
</span><span id="line-782"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WarningFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#wopt"><span class="hs-identifier hs-var">wopt</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnMissedSpecs"><span class="hs-identifier hs-var">Opt_WarnMissedSpecs</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967289"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-783"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967288"><span class="hs-identifier hs-var">callers</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-784"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680967282"><span class="hs-identifier hs-var">allCallersInlined</span></a></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WarnReason -&gt; CoreM ()
</span><a href="#local-6989586621680967281"><span class="hs-identifier hs-var">doWarn</span></a></span><span> </span><span class="annot"><span class="annottext">(WarnReason -&gt; CoreM ()) -&gt; WarnReason -&gt; CoreM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag -&gt; WarnReason
</span><a href="GHC.Driver.Flags.html#Reason"><span class="hs-identifier hs-var">Reason</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnMissedSpecs"><span class="hs-identifier hs-var">Opt_WarnMissedSpecs</span></a></span><span>
</span><span id="line-785"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WarningFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#wopt"><span class="hs-identifier hs-var">wopt</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnAllMissedSpecs"><span class="hs-identifier hs-var">Opt_WarnAllMissedSpecs</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967289"><span class="hs-identifier hs-var">dflags</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WarnReason -&gt; CoreM ()
</span><a href="#local-6989586621680967281"><span class="hs-identifier hs-var">doWarn</span></a></span><span> </span><span class="annot"><span class="annottext">(WarnReason -&gt; CoreM ()) -&gt; WarnReason -&gt; CoreM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag -&gt; WarnReason
</span><a href="GHC.Driver.Flags.html#Reason"><span class="hs-identifier hs-var">Reason</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnAllMissedSpecs"><span class="hs-identifier hs-var">Opt_WarnAllMissedSpecs</span></a></span><span>
</span><span id="line-786"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; CoreM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-787"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-788"></span><span>    </span><span id="local-6989586621680967282"><span class="annot"><span class="annottext">allCallersInlined :: Bool
</span><a href="#local-6989586621680967282"><span class="hs-identifier hs-var hs-var">allCallersInlined</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InlinePragma -&gt; Bool
</span><a href="GHC.Types.Basic.html#isAnyInlinePragma"><span class="hs-identifier hs-var">isAnyInlinePragma</span></a></span><span> </span><span class="annot"><span class="annottext">(InlinePragma -&gt; Bool) -&gt; (Id -&gt; InlinePragma) -&gt; Id -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; InlinePragma
</span><a href="GHC.Types.Id.html#idInlinePragma"><span class="hs-identifier hs-var">idInlinePragma</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967288"><span class="hs-identifier hs-var">callers</span></a></span><span>
</span><span id="line-789"></span><span>    </span><span id="local-6989586621680967281"><span class="annot"><span class="annottext">doWarn :: WarnReason -&gt; CoreM ()
</span><a href="#local-6989586621680967281"><span class="hs-identifier hs-var hs-var">doWarn</span></a></span></span><span> </span><span id="local-6989586621680967270"><span class="annot"><span class="annottext">WarnReason
</span><a href="#local-6989586621680967270"><span class="hs-identifier hs-var">reason</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-790"></span><span>      </span><span class="annot"><span class="annottext">WarnReason -&gt; SDoc -&gt; CoreM ()
</span><a href="GHC.Core.Opt.Monad.html#warnMsg"><span class="hs-identifier hs-var">warnMsg</span></a></span><span> </span><span class="annot"><span class="annottext">WarnReason
</span><a href="#local-6989586621680967270"><span class="hs-identifier hs-var">reason</span></a></span><span>
</span><span id="line-791"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Could not specialise imported function&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967287"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-792"></span><span>                </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;when specialising&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967262"><span class="hs-identifier hs-var">caller</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-793"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621680967262"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967262"><span class="hs-identifier hs-var">caller</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967288"><span class="hs-identifier hs-var">callers</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-794"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#whenPprDebug"><span class="hs-identifier hs-var">whenPprDebug</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;calls:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CallInfo -&gt; SDoc) -&gt; [CallInfo] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CallInfo -&gt; SDoc
</span><a href="GHC.Core.Opt.Specialise.html#pprCallInfo"><span class="hs-identifier hs-var">pprCallInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967287"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680967286"><span class="hs-identifier hs-var">calls_for_fn</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-795"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Probable fix: add INLINABLE pragma on&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967287"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-796"></span><span>
</span><span id="line-797"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#wantSpecImport"><span class="hs-identifier hs-type">wantSpecImport</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Unfolding"><span class="hs-identifier hs-type">Unfolding</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-798"></span><span class="hs-comment">-- See Note [Specialise imported INLINABLE things]</span><span>
</span><span id="line-799"></span><span id="wantSpecImport"><span class="annot"><span class="annottext">wantSpecImport :: DynFlags -&gt; Unfolding -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#wantSpecImport"><span class="hs-identifier hs-var hs-var">wantSpecImport</span></a></span></span><span> </span><span id="local-6989586621680967259"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967259"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680967258"><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680967258"><span class="hs-identifier hs-var">unf</span></a></span></span><span>
</span><span id="line-800"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680967258"><span class="hs-identifier hs-var">unf</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-801"></span><span>     </span><span class="annot"><span class="annottext">Unfolding
</span><a href="GHC.Core.html#NoUnfolding"><span class="hs-identifier hs-var">NoUnfolding</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-802"></span><span>     </span><span class="annot"><span class="annottext">Unfolding
</span><a href="GHC.Core.html#BootUnfolding"><span class="hs-identifier hs-var">BootUnfolding</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-803"></span><span>     </span><span class="annot"><a href="GHC.Core.html#OtherCon"><span class="hs-identifier hs-type">OtherCon</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-804"></span><span>     </span><span class="annot"><a href="GHC.Core.html#DFunUnfolding"><span class="hs-identifier hs-type">DFunUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-805"></span><span>     </span><span class="annot"><a href="GHC.Core.html#CoreUnfolding"><span class="hs-identifier hs-type">CoreUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_src :: Unfolding -&gt; UnfoldingSource
</span><a href="GHC.Core.html#uf_src"><span class="hs-identifier hs-var">uf_src</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967251"><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621680967251"><span class="hs-identifier hs-var">src</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uf_guidance :: Unfolding -&gt; UnfoldingGuidance
</span><a href="GHC.Core.html#uf_guidance"><span class="hs-identifier hs-var">uf_guidance</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967249"><span class="annot"><span class="annottext">UnfoldingGuidance
</span><a href="#local-6989586621680967249"><span class="hs-identifier hs-var">_guidance</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-806"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_SpecialiseAggressively"><span class="hs-identifier hs-var">Opt_SpecialiseAggressively</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680967259"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-807"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UnfoldingSource -&gt; Bool
</span><a href="GHC.Core.html#isStableSource"><span class="hs-identifier hs-var">isStableSource</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621680967251"><span class="hs-identifier hs-var">src</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-808"></span><span>               </span><span class="hs-comment">-- Specialise even INLINE things; it hasn't inlined yet,</span><span>
</span><span id="line-809"></span><span>               </span><span class="hs-comment">-- so perhaps it never will.  Moreover it may have calls</span><span>
</span><span id="line-810"></span><span>               </span><span class="hs-comment">-- inside it that we want to specialise</span><span>
</span><span id="line-811"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>    </span><span class="hs-comment">-- Stable, not INLINE, hence INLINABLE</span><span>
</span><span id="line-812"></span><span>
</span><span id="line-813"></span><span class="hs-comment">{- Note [Avoiding loops in specImports]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We must take great care when specialising instance declarations
(functions like $fOrdList) lest we accidentally build a recursive
dictionary. See Note [Avoiding loops].

The basic strategy of Note [Avoiding loops] is to use filterCalls
to discard loopy specialisations.  But to do that we must ensure
that the in-scope dict-binds (passed to filterCalls) contains
all the needed dictionary bindings.  In particular, in the recursive
call to spec_imorpts in spec_import, we must include the dict-binds
from the parent.  Lacking this caused #17151, a really nasty bug.

Here is what happened.
* Class struture:
    Source is a superclass of Mut
    Index is a superclass of Source

* We started with these dict binds
    dSource = $fSourcePix @Int $fIndexInt
    dIndex  = sc_sel dSource
    dMut    = $fMutPix @Int dIndex
  and these calls to specialise
    $fMutPix @Int dIndex
    $fSourcePix @Int $fIndexInt

* We specialised the call ($fMutPix @Int dIndex)
  ==&gt; new call ($fSourcePix @Int dIndex)
      (because Source is a superclass of Mut)

* We specialised ($fSourcePix @Int dIndex)
  ==&gt; produces specialised dict $s$fSourcePix,
      a record with dIndex as a field
      plus RULE forall d. ($fSourcePix @Int d) = $s$fSourcePix
  *** This is the bogus step ***

* Now we decide not to specialise the call
    $fSourcePix @Int $fIndexInt
  because we alredy have a RULE that matches it

* Finally the simplifer rewrites
    dSource = $fSourcePix @Int $fIndexInt
    ==&gt;  dSource = $s$fSourcePix

Disaster. Now we have

Rewrite dSource's RHS to $s$fSourcePix   Disaster
    dSource = $s$fSourcePix
    dIndex  = sc_sel dSource
    $s$fSourcePix = MkSource dIndex ...

Solution: filterCalls should have stopped the bogus step,
by seeing that dIndex transitively uses $fSourcePix. But
it can only do that if it sees all the dict_binds.  Wow.

--------------
Here's another example (#13429).  Suppose we have
  class Monoid v =&gt; C v a where ...

We start with a call
   f @ [Integer] @ Integer $fC[]Integer

Specialising call to 'f' gives dict bindings
   $dMonoid_1 :: Monoid [Integer]
   $dMonoid_1 = M.$p1C @ [Integer] $fC[]Integer

   $dC_1 :: C [Integer] (Node [Integer] Integer)
   $dC_1 = M.$fCvNode @ [Integer] $dMonoid_1

...plus a recursive call to
   f @ [Integer] @ (Node [Integer] Integer) $dC_1

Specialising that call gives
   $dMonoid_2  :: Monoid [Integer]
   $dMonoid_2  = M.$p1C @ [Integer] $dC_1

   $dC_2 :: C [Integer] (Node [Integer] Integer)
   $dC_2 = M.$fCvNode @ [Integer] $dMonoid_2

Now we have two calls to the imported function
  M.$fCvNode :: Monoid v =&gt; C v a
  M.$fCvNode @v @a m = C m some_fun

But we must /not/ use the call (M.$fCvNode @ [Integer] $dMonoid_2)
for specialisation, else we get:

  $dC_1 = M.$fCvNode @ [Integer] $dMonoid_1
  $dMonoid_2 = M.$p1C @ [Integer] $dC_1
  $s$fCvNode = C $dMonoid_2 ...
    RULE M.$fCvNode [Integer] _ _ = $s$fCvNode

Now use the rule to rewrite the call in the RHS of $dC_1
and we get a loop!


Note [specImport call stack]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When specialising an imports function 'f', we may get new calls
of an imported fuction 'g', which we want to specialise in turn,
and similarly specialising 'g' might expose a new call to 'h'.

We track the stack of enclosing functions. So when specialising 'h' we
haev a specImport call stack of [g,f]. We do this for two reasons:
* Note [Warning about missed specialisations]
* Note [Avoiding recursive specialisation]

Note [Warning about missed specialisations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose
 * In module Lib, you carefully mark a function 'foo' INLINABLE
 * Import Lib(foo) into another module M
 * Call 'foo' at some specialised type in M
Then you jolly well expect it to be specialised in M.  But what if
'foo' calls another function 'Lib.bar'.  Then you'd like 'bar' to be
specialised too.  But if 'bar' is not marked INLINABLE it may well
not be specialised.  The warning Opt_WarnMissedSpecs warns about this.

It's more noisy to warning about a missed specialisation opportunity
for /every/ overloaded imported function, but sometimes useful. That
is what Opt_WarnAllMissedSpecs does.

ToDo: warn about missed opportunities for local functions.

Note [Avoiding recursive specialisation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we specialise 'f' we may find new overloaded calls to 'g', 'h' in
'f's RHS.  So we want to specialise g,h.  But we don't want to
specialise f any more!  It's possible that f's RHS might have a
recursive yet-more-specialised call, so we'd diverge in that case.
And if the call is to the same type, one specialisation is enough.
Avoiding this recursive specialisation loop is one reason for the
'callers' stack passed to specImports and specImport.

Note [Specialise imported INLINABLE things]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What imported functions do we specialise?  The basic set is
 * DFuns and things with INLINABLE pragmas.
but with -fspecialise-aggressively we add
 * Anything with an unfolding template

#8874 has a good example of why we want to auto-specialise DFuns.

We have the -fspecialise-aggressively flag (usually off), because we
risk lots of orphan modules from over-vigorous specialisation.
However it's not a big deal: anything non-recursive with an
unfolding-template will probably have been inlined already.

Note [Glom the bindings if imported functions are specialised]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have an imported, *recursive*, INLINABLE function
   f :: Eq a =&gt; a -&gt; a
   f = /\a \d x. ...(f a d)...
In the module being compiled we have
   g x = f (x::Int)
Now we'll make a specialised function
   f_spec :: Int -&gt; Int
   f_spec = \x -&gt; ...(f Int dInt)...
   {-# RULE  f Int _ = f_spec #-}
   g = \x. f Int dInt x
Note that f_spec doesn't look recursive
After rewriting with the RULE, we get
   f_spec = \x -&gt; ...(f_spec)...
BUT since f_spec was non-recursive before it'll *stay* non-recursive.
The occurrence analyser never turns a NonRec into a Rec.  So we must
make sure that f_spec is recursive.  Easiest thing is to make all
the specialisations for imported bindings recursive.



************************************************************************
*                                                                      *
\subsubsection{@specExpr@: the main function}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-988"></span><span>
</span><span id="line-989"></span><span class="hs-keyword">data</span><span> </span><span id="SpecEnv"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-var">SpecEnv</span></a></span></span><span>
</span><span id="line-990"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="SE"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SE"><span class="hs-identifier hs-var">SE</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="se_subst"><span class="annot"><span class="annottext">SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var hs-var">se_subst</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Core.Subst</span></a></span><span>
</span><span id="line-991"></span><span>             </span><span class="hs-comment">-- We carry a substitution down:</span><span>
</span><span id="line-992"></span><span>             </span><span class="hs-comment">-- a) we must clone any binding that might float outwards,</span><span>
</span><span id="line-993"></span><span>             </span><span class="hs-comment">--    to avoid name clashes</span><span>
</span><span id="line-994"></span><span>             </span><span class="hs-comment">-- b) we carry a type substitution to use when analysing</span><span>
</span><span id="line-995"></span><span>             </span><span class="hs-comment">--    the RHS of specialised bindings (no type-let!)</span><span>
</span><span id="line-996"></span><span>
</span><span id="line-997"></span><span>
</span><span id="line-998"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="se_interesting"><span class="annot"><span class="annottext">SpecEnv -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var hs-var">se_interesting</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-999"></span><span>             </span><span class="hs-comment">-- Dict Ids that we know something about</span><span>
</span><span id="line-1000"></span><span>             </span><span class="hs-comment">-- and hence may be worth specialising against</span><span>
</span><span id="line-1001"></span><span>             </span><span class="hs-comment">-- See Note [Interesting dictionary arguments]</span><span>
</span><span id="line-1002"></span><span>     </span><span class="hs-special">}</span><span>
</span><span id="line-1003"></span><span>
</span><span id="line-1004"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680967244"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1005"></span><span>  </span><span id="local-6989586621680967238"><span class="annot"><span class="annottext">ppr :: SpecEnv -&gt; SDoc
</span><a href="#local-6989586621680967238"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SE"><span class="hs-identifier hs-type">SE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967237"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680967237"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">se_interesting :: SpecEnv -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var">se_interesting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680967236"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680967236"><span class="hs-identifier hs-var">interesting</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1006"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;SE&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; [SDoc] -&gt; [SDoc]
</span><a href="GHC.Utils.Outputable.html#punctuate"><span class="hs-identifier hs-var">punctuate</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span>
</span><span id="line-1007"></span><span>        </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;subst =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Subst -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680967237"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-1008"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;interesting =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680967236"><span class="hs-identifier hs-var">interesting</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1009"></span><span>
</span><span id="line-1010"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specVar"><span class="hs-identifier hs-type">specVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-1011"></span><span id="specVar"><span class="annot"><span class="annottext">specVar :: SpecEnv -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Specialise.html#specVar"><span class="hs-identifier hs-var hs-var">specVar</span></a></span></span><span> </span><span id="local-6989586621680967230"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967230"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680967229"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967229"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; Id -&gt; CoreExpr
Subst -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#lookupIdSubst"><span class="hs-identifier hs-var">Core.lookupIdSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var hs-var">se_subst</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967230"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967229"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-1012"></span><span>
</span><span id="line-1013"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-type">specExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1014"></span><span>
</span><span id="line-1015"></span><span class="hs-comment">---------------- First the easy cases --------------------</span><span>
</span><span id="line-1016"></span><span id="specExpr"><span class="annot"><span class="annottext">specExpr :: SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var hs-var">specExpr</span></a></span></span><span> </span><span id="local-6989586621680967226"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967226"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span id="local-6989586621680967224"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680967224"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; CoreExpr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span>     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Type -&gt; Type
</span><a href="GHC.Core.Opt.Specialise.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967226"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680967224"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var">emptyUDs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1017"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span id="local-6989586621680967222"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967222"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span id="local-6989586621680967220"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680967220"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; CoreExpr
forall b. Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-var">Coercion</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Opt.Specialise.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967222"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680967220"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var">emptyUDs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1018"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span id="local-6989586621680967218"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967218"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680967216"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967216"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Specialise.html#specVar"><span class="hs-identifier hs-var">specVar</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967218"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967216"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var">emptyUDs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1019"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-type">Lit</span></a></span><span> </span><span id="local-6989586621680967214"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680967214"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Literal -&gt; CoreExpr
forall b. Literal -&gt; Expr b
</span><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-var">Lit</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680967214"><span class="hs-identifier hs-var">lit</span></a></span><span class="hs-special">,</span><span>       </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var">emptyUDs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1020"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span id="local-6989586621680967213"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967213"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680967211"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967211"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680967210"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680967210"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1021"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967209"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967209"><span class="hs-identifier hs-var">e'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967208"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967208"><span class="hs-identifier hs-var">uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967213"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967211"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1022"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Coercion -&gt; CoreExpr
</span><a href="GHC.Core.Utils.html#mkCast"><span class="hs-identifier hs-var">mkCast</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967209"><span class="hs-identifier hs-var">e'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Opt.Specialise.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967213"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680967210"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967208"><span class="hs-identifier hs-var">uds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1023"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span id="local-6989586621680967207"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967207"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680967205"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680967205"><span class="hs-identifier hs-var">tickish</span></a></span></span><span> </span><span id="local-6989586621680967204"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967204"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1024"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967203"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967203"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967202"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967202"><span class="hs-identifier hs-var">uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967207"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967204"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-1025"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tickish Id -&gt; CoreExpr -&gt; CoreExpr
forall b. Tickish Id -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-var">Tick</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Tickish Id -&gt; Tickish Id
</span><a href="GHC.Core.Opt.Specialise.html#specTickish"><span class="hs-identifier hs-var">specTickish</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967207"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680967205"><span class="hs-identifier hs-var">tickish</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967203"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967202"><span class="hs-identifier hs-var">uds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1026"></span><span>
</span><span id="line-1027"></span><span class="hs-comment">---------------- Applications might generate a call instance --------------------</span><span>
</span><span id="line-1028"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span id="local-6989586621680967200"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967200"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680967199"><span class="annot"><span class="annottext">expr :: CoreExpr
</span><a href="#local-6989586621680967199"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1029"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="#local-6989586621680967197"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967199"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1030"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1031"></span><span>    </span><span id="local-6989586621680967197"><span class="annot"><span class="annottext">go :: CoreExpr -&gt; [CoreExpr] -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="#local-6989586621680967197"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680967191"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967191"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621680967190"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967190"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680967189"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680967189"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967188"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967188"><span class="hs-identifier hs-var">arg'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967187"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967187"><span class="hs-identifier hs-var">uds_arg</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967200"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967190"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-1032"></span><span>                               </span><span class="hs-special">(</span><span id="local-6989586621680967186"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967186"><span class="hs-identifier hs-var">fun'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967185"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967185"><span class="hs-identifier hs-var">uds_app</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="#local-6989586621680967197"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967191"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967188"><span class="hs-identifier hs-var">arg'</span></a></span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680967189"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1033"></span><span>                               </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967186"><span class="hs-identifier hs-var">fun'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967188"><span class="hs-identifier hs-var">arg'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967187"><span class="hs-identifier hs-var">uds_arg</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#plusUDs"><span class="hs-operator hs-var">`plusUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967185"><span class="hs-identifier hs-var">uds_app</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1034"></span><span>
</span><span id="line-1035"></span><span>    </span><span class="annot"><a href="#local-6989586621680967197"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680967183"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967183"><span class="hs-identifier hs-var">f</span></a></span></span><span class="hs-special">)</span><span>       </span><span id="local-6989586621680967182"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680967182"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Specialise.html#specVar"><span class="hs-identifier hs-var">specVar</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967200"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967183"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1036"></span><span>                                </span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680967181"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967181"><span class="hs-identifier hs-var">f'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967181"><span class="hs-identifier hs-var">f'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; Id -&gt; [CoreExpr] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#mkCallUDs"><span class="hs-identifier hs-var">mkCallUDs</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967200"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967181"><span class="hs-identifier hs-var">f'</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680967182"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1037"></span><span>                                </span><span id="local-6989586621680967179"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967179"><span class="hs-identifier hs-var">e'</span></a></span></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967179"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var">emptyUDs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- I don't expect this!</span><span>
</span><span id="line-1038"></span><span>    </span><span class="annot"><a href="#local-6989586621680967197"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680967178"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967178"><span class="hs-identifier hs-var">other</span></a></span></span><span>         </span><span class="annot"><span class="annottext">[CoreExpr]
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967200"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967178"><span class="hs-identifier hs-var">other</span></a></span><span>
</span><span id="line-1039"></span><span>
</span><span id="line-1040"></span><span class="hs-comment">---------------- Lambda/case require dumping of usage details --------------------</span><span>
</span><span id="line-1041"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span id="local-6989586621680967177"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967177"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680967176"><span class="annot"><span class="annottext">e :: CoreExpr
</span><a href="#local-6989586621680967176"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1042"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; [Id] -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specLam"><span class="hs-identifier hs-var">specLam</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967173"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967172"><span class="hs-identifier hs-var">bndrs'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967171"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-1043"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1044"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680967170"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967170"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967171"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967171"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; ([Id], CoreExpr)
forall b. Expr b -&gt; ([b], Expr b)
</span><a href="GHC.Core.html#collectBinders"><span class="hs-identifier hs-var">collectBinders</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967176"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1045"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680967173"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967173"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967172"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967172"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; [Id] -&gt; (SpecEnv, [Id])
</span><a href="GHC.Core.Opt.Specialise.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967177"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967170"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1046"></span><span>        </span><span class="hs-comment">-- More efficient to collect a group of binders together all at once</span><span>
</span><span id="line-1047"></span><span>        </span><span class="hs-comment">-- and we don't want to split a lambda group with dumped bindings</span><span>
</span><span id="line-1048"></span><span>
</span><span id="line-1049"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span id="local-6989586621680967167"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967167"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Case"><span class="hs-identifier hs-type">Case</span></a></span><span> </span><span id="local-6989586621680967165"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967165"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680967164"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967164"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span id="local-6989586621680967163"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680967163"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680967162"><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680967162"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1050"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967161"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967161"><span class="hs-identifier hs-var">scrut'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967160"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967160"><span class="hs-identifier hs-var">scrut_uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967167"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967165"><span class="hs-identifier hs-var">scrut</span></a></span><span>
</span><span id="line-1051"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967159"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967159"><span class="hs-identifier hs-var">scrut''</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967158"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967158"><span class="hs-identifier hs-var">case_bndr'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967157"><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680967157"><span class="hs-identifier hs-var">alts'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967156"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967156"><span class="hs-identifier hs-var">alts_uds</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1052"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; CoreExpr
-&gt; Id
-&gt; [Alt Id]
-&gt; SpecM (CoreExpr, Id, [Alt Id], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specCase"><span class="hs-identifier hs-var">specCase</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967167"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967161"><span class="hs-identifier hs-var">scrut'</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967164"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680967162"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-1053"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Id -&gt; Type -&gt; [Alt Id] -&gt; CoreExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967159"><span class="hs-identifier hs-var">scrut''</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967158"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Type -&gt; Type
</span><a href="GHC.Core.Opt.Specialise.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967167"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680967163"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680967157"><span class="hs-identifier hs-var">alts'</span></a></span><span>
</span><span id="line-1054"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967160"><span class="hs-identifier hs-var">scrut_uds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#plusUDs"><span class="hs-operator hs-var">`plusUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967156"><span class="hs-identifier hs-var">alts_uds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1055"></span><span>
</span><span id="line-1056"></span><span class="hs-comment">---------------- Finally, let is the interesting case --------------------</span><span>
</span><span id="line-1057"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span id="local-6989586621680967154"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967154"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span id="local-6989586621680967152"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680967152"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span id="local-6989586621680967151"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967151"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1058"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- Clone binders</span><span>
</span><span id="line-1059"></span><span>         </span><span class="hs-special">(</span><span id="local-6989586621680967150"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967150"><span class="hs-identifier hs-var">rhs_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967149"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967149"><span class="hs-identifier hs-var">body_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967148"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680967148"><span class="hs-identifier hs-var">bind'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreBind -&gt; SpecM (SpecEnv, SpecEnv, CoreBind)
</span><a href="GHC.Core.Opt.Specialise.html#cloneBindSM"><span class="hs-identifier hs-var">cloneBindSM</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967154"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680967152"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-1060"></span><span>
</span><span id="line-1061"></span><span>         </span><span class="hs-comment">-- Deal with the body</span><span>
</span><span id="line-1062"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967146"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967146"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967145"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967145"><span class="hs-identifier hs-var">body_uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967149"><span class="hs-identifier hs-var">body_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967151"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-1063"></span><span>
</span><span id="line-1064"></span><span>        </span><span class="hs-comment">-- Deal with the bindings</span><span>
</span><span id="line-1065"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967144"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967144"><span class="hs-identifier hs-var">binds'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967143"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967143"><span class="hs-identifier hs-var">uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; CoreBind -&gt; UsageDetails -&gt; SpecM (CoreProgram, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specBind"><span class="hs-identifier hs-var">specBind</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967150"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680967148"><span class="hs-identifier hs-var">bind'</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967145"><span class="hs-identifier hs-var">body_uds</span></a></span><span>
</span><span id="line-1066"></span><span>
</span><span id="line-1067"></span><span>        </span><span class="hs-comment">-- All done</span><span>
</span><span id="line-1068"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CoreBind -&gt; CoreExpr -&gt; CoreExpr)
-&gt; CoreExpr -&gt; CoreProgram -&gt; CoreExpr
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; CoreExpr -&gt; CoreExpr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967146"><span class="hs-identifier hs-var">body'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680967144"><span class="hs-identifier hs-var">binds'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967143"><span class="hs-identifier hs-var">uds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1069"></span><span>
</span><span id="line-1070"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1071"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specLam"><span class="hs-identifier hs-type">specLam</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1072"></span><span class="hs-comment">-- The binders have been substituted, but the body has not</span><span>
</span><span id="line-1073"></span><span id="specLam"><span class="annot"><span class="annottext">specLam :: SpecEnv -&gt; [Id] -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specLam"><span class="hs-identifier hs-var hs-var">specLam</span></a></span></span><span> </span><span id="local-6989586621680967138"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967138"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680967137"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967137"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span id="local-6989586621680967136"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967136"><span class="hs-identifier hs-var">body</span></a></span></span><span>
</span><span id="line-1074"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967137"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1075"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967138"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967136"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-1076"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1077"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967135"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967135"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967134"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967134"><span class="hs-identifier hs-var">uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967138"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967136"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-1078"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967133"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967133"><span class="hs-identifier hs-var">free_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967132"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967132"><span class="hs-identifier hs-var">dumped_dbs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; UsageDetails -&gt; (UsageDetails, Bag DictBind)
</span><a href="GHC.Core.Opt.Specialise.html#dumpUDs"><span class="hs-identifier hs-var">dumpUDs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967137"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967134"><span class="hs-identifier hs-var">uds</span></a></span><span>
</span><span id="line-1079"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, UsageDetails) -&gt; SpecM (CoreExpr, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967137"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag DictBind -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Specialise.html#wrapDictBindsE"><span class="hs-identifier hs-var">wrapDictBindsE</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967132"><span class="hs-identifier hs-var">dumped_dbs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967135"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967133"><span class="hs-identifier hs-var">free_uds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1080"></span><span>
</span><span id="line-1081"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1082"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specTickish"><span class="hs-identifier hs-type">specTickish</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Tickish"><span class="hs-identifier hs-type">Tickish</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Tickish"><span class="hs-identifier hs-type">Tickish</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-1083"></span><span id="specTickish"><span class="annot"><span class="annottext">specTickish :: SpecEnv -&gt; Tickish Id -&gt; Tickish Id
</span><a href="GHC.Core.Opt.Specialise.html#specTickish"><span class="hs-identifier hs-var hs-var">specTickish</span></a></span></span><span> </span><span id="local-6989586621680967128"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967128"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Breakpoint"><span class="hs-identifier hs-type">Breakpoint</span></a></span><span> </span><span id="local-6989586621680967126"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680967126"><span class="hs-identifier hs-var">ix</span></a></span></span><span> </span><span id="local-6989586621680967125"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967125"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1084"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [Id] -&gt; Tickish Id
forall id. Int -&gt; [id] -&gt; Tickish id
</span><a href="GHC.Core.html#Breakpoint"><span class="hs-identifier hs-var">Breakpoint</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680967126"><span class="hs-identifier hs-var">ix</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967124"><span class="hs-identifier hs-var">id'</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621680967123"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967123"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967125"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680967124"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967124"><span class="hs-identifier hs-var">id'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">SpecEnv -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Specialise.html#specVar"><span class="hs-identifier hs-var">specVar</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967128"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967123"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">]</span><span class="hs-special">]</span><span>
</span><span id="line-1085"></span><span>  </span><span class="hs-comment">-- drop vars from the list if they have a non-variable substitution.</span><span>
</span><span id="line-1086"></span><span>  </span><span class="hs-comment">-- should never happen, but it's harmless to drop them anyway.</span><span>
</span><span id="line-1087"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specTickish"><span class="hs-identifier hs-var">specTickish</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680967122"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680967122"><span class="hs-identifier hs-var">other_tickish</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680967122"><span class="hs-identifier hs-var">other_tickish</span></a></span><span>
</span><span id="line-1088"></span><span>
</span><span id="line-1089"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1090"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specCase"><span class="hs-identifier hs-type">specCase</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>
</span><span id="line-1091"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>            </span><span class="hs-comment">-- Scrutinee, already done</span><span>
</span><span id="line-1092"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreAlt"><span class="hs-identifier hs-type">CoreAlt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1093"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>    </span><span class="hs-comment">-- New scrutinee</span><span>
</span><span id="line-1094"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-1095"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreAlt"><span class="hs-identifier hs-type">CoreAlt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1096"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1097"></span><span id="specCase"><span class="annot"><span class="annottext">specCase :: SpecEnv
-&gt; CoreExpr
-&gt; Id
-&gt; [Alt Id]
-&gt; SpecM (CoreExpr, Id, [Alt Id], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specCase"><span class="hs-identifier hs-var hs-var">specCase</span></a></span></span><span> </span><span id="local-6989586621680967120"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967120"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680967119"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967119"><span class="hs-identifier hs-var">scrut'</span></a></span></span><span> </span><span id="local-6989586621680967118"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967118"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span id="local-6989586621680967117"><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680967117"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967116"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967116"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967115"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967115"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-1098"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isDictId"><span class="hs-identifier hs-var">isDictId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967118"><span class="hs-identifier hs-var">case_bndr</span></a></span><span>           </span><span class="hs-comment">-- See Note [Floating dictionaries out of cases]</span><span>
</span><span id="line-1099"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967120"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967119"><span class="hs-identifier hs-var">scrut'</span></a></span><span>
</span><span id="line-1100"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isDeadBinder"><span class="hs-identifier hs-var">isDeadBinder</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967118"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967111"><span class="hs-identifier hs-var">sc_args'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1101"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967110"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967110"><span class="hs-identifier hs-var">case_bndr_flt</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680967109"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967109"><span class="hs-identifier hs-var">sc_args_flt</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; SpecM Id) -&gt; [Id] -&gt; SpecM [Id]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SpecM Id
forall {m :: * -&gt; *}. MonadUnique m =&gt; Id -&gt; m Id
</span><a href="#local-6989586621680967107"><span class="hs-identifier hs-var">clone_me</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967106"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967111"><span class="hs-identifier hs-var">sc_args'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1102"></span><span>
</span><span id="line-1103"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680967105"><span class="annot"><span class="annottext">sc_rhss :: [CoreExpr]
</span><a href="#local-6989586621680967105"><span class="hs-identifier hs-var hs-var">sc_rhss</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Id -&gt; Type -&gt; [Alt Id] -&gt; CoreExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967110"><span class="hs-identifier hs-var">case_bndr_flt</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967106"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967103"><span class="hs-identifier hs-var">sc_arg'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1104"></span><span>                              </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680967117"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967102"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967103"><span class="hs-identifier hs-var">sc_arg'</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-1105"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621680967103"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967103"><span class="hs-identifier hs-var">sc_arg'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967111"><span class="hs-identifier hs-var">sc_args'</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1106"></span><span>
</span><span id="line-1107"></span><span>             </span><span class="hs-comment">-- Extend the substitution for RHS to map the *original* binders</span><span>
</span><span id="line-1108"></span><span>             </span><span class="hs-comment">-- to their floated versions.</span><span>
</span><span id="line-1109"></span><span>             </span><span class="annot"><a href="#local-6989586621680967101"><span class="hs-identifier hs-type">mb_sc_flts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DictId"><span class="hs-identifier hs-type">DictId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1110"></span><span>             </span><span id="local-6989586621680967101"><span class="annot"><span class="annottext">mb_sc_flts :: [Maybe Id]
</span><a href="#local-6989586621680967101"><span class="hs-identifier hs-var hs-var">mb_sc_flts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Maybe Id) -&gt; [Id] -&gt; [Maybe Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarEnv Id -&gt; Id -&gt; Maybe Id
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621680967098"><span class="hs-identifier hs-var">clone_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967102"><span class="hs-identifier hs-var">args'</span></a></span><span>
</span><span id="line-1111"></span><span>             </span><span id="local-6989586621680967098"><span class="annot"><span class="annottext">clone_env :: VarEnv Id
</span><a href="#local-6989586621680967098"><span class="hs-identifier hs-var hs-var">clone_env</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; VarEnv Id
forall a. [Id] -&gt; [a] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#zipVarEnv"><span class="hs-identifier hs-var">zipVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967111"><span class="hs-identifier hs-var">sc_args'</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967109"><span class="hs-identifier hs-var">sc_args_flt</span></a></span><span>
</span><span id="line-1112"></span><span>             </span><span id="local-6989586621680967096"><span class="annot"><span class="annottext">subst_prs :: [(Id, Expr b)]
</span><a href="#local-6989586621680967096"><span class="hs-identifier hs-var hs-var">subst_prs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967118"><span class="hs-identifier hs-var">case_bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Expr b
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967110"><span class="hs-identifier hs-var">case_bndr_flt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1113"></span><span>                        </span><span class="annot"><span class="annottext">(Id, Expr b) -&gt; [(Id, Expr b)] -&gt; [(Id, Expr b)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967095"><span class="hs-identifier hs-var">arg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Expr b
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967094"><span class="hs-identifier hs-var">sc_flt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1114"></span><span>                          </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967095"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967095"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680967094"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967094"><span class="hs-identifier hs-var">sc_flt</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967116"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Maybe Id] -&gt; [(Id, Maybe Id)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Id]
</span><a href="#local-6989586621680967101"><span class="hs-identifier hs-var">mb_sc_flts</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1115"></span><span>             </span><span id="local-6989586621680967093"><span class="annot"><span class="annottext">env_rhs' :: SpecEnv
</span><a href="#local-6989586621680967093"><span class="hs-identifier hs-var hs-var">env_rhs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967092"><span class="hs-identifier hs-var">env_rhs</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [(Id, CoreExpr)] -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendIdSubstList"><span class="hs-identifier hs-var">Core.extendIdSubstList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var hs-var">se_subst</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967092"><span class="hs-identifier hs-var">env_rhs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
forall {b}. [(Id, Expr b)]
</span><a href="#local-6989586621680967096"><span class="hs-identifier hs-var">subst_prs</span></a></span><span>
</span><span id="line-1116"></span><span>                                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">se_interesting :: VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var">se_interesting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var hs-var">se_interesting</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967092"><span class="hs-identifier hs-var">env_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSetList"><span class="hs-operator hs-var">`extendVarSetList`</span></a></span><span>
</span><span id="line-1117"></span><span>                                                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967110"><span class="hs-identifier hs-var">case_bndr_flt</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967109"><span class="hs-identifier hs-var">sc_args_flt</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1118"></span><span>
</span><span id="line-1119"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967089"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967089"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967088"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967088"><span class="hs-identifier hs-var">rhs_uds</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967093"><span class="hs-identifier hs-var">env_rhs'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967115"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1120"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680967087"><span class="annot"><span class="annottext">scrut_bind :: DictBind
</span><a href="#local-6989586621680967087"><span class="hs-identifier hs-var hs-var">scrut_bind</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#mkDB"><span class="hs-identifier hs-var">mkDB</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967110"><span class="hs-identifier hs-var">case_bndr_flt</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967119"><span class="hs-identifier hs-var">scrut'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1121"></span><span>             </span><span id="local-6989586621680967085"><span class="annot"><span class="annottext">case_bndr_set :: VarSet
</span><a href="#local-6989586621680967085"><span class="hs-identifier hs-var hs-var">case_bndr_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unitVarSet"><span class="hs-identifier hs-var">unitVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967110"><span class="hs-identifier hs-var">case_bndr_flt</span></a></span><span>
</span><span id="line-1122"></span><span>             </span><span id="local-6989586621680967083"><span class="annot"><span class="annottext">sc_binds :: [DictBind]
</span><a href="#local-6989586621680967083"><span class="hs-identifier hs-var hs-var">sc_binds</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">DB :: CoreBind -&gt; VarSet -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#DB"><span class="hs-identifier hs-type">DB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">db_bind :: CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var">db_bind</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967080"><span class="hs-identifier hs-var">sc_arg_flt</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967079"><span class="hs-identifier hs-var">sc_rhs</span></a></span><span>
</span><span id="line-1123"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">db_fvs :: VarSet
</span><a href="GHC.Core.Opt.Specialise.html#db_fvs"><span class="hs-identifier hs-var">db_fvs</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680967085"><span class="hs-identifier hs-var">case_bndr_set</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1124"></span><span>                             </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967080"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967080"><span class="hs-identifier hs-var">sc_arg_flt</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967079"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967079"><span class="hs-identifier hs-var">sc_rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967109"><span class="hs-identifier hs-var">sc_args_flt</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [CoreExpr] -&gt; [(Id, CoreExpr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680967105"><span class="hs-identifier hs-var">sc_rhss</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1125"></span><span>             </span><span id="local-6989586621680967077"><span class="annot"><span class="annottext">flt_binds :: [DictBind]
</span><a href="#local-6989586621680967077"><span class="hs-identifier hs-var hs-var">flt_binds</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680967087"><span class="hs-identifier hs-var">scrut_bind</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind -&gt; [DictBind] -&gt; [DictBind]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680967083"><span class="hs-identifier hs-var">sc_binds</span></a></span><span>
</span><span id="line-1126"></span><span>             </span><span class="hs-special">(</span><span id="local-6989586621680967076"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967076"><span class="hs-identifier hs-var">free_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967075"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967075"><span class="hs-identifier hs-var">dumped_dbs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; UsageDetails -&gt; (UsageDetails, Bag DictBind)
</span><a href="GHC.Core.Opt.Specialise.html#dumpUDs"><span class="hs-identifier hs-var">dumpUDs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967106"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967102"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967088"><span class="hs-identifier hs-var">rhs_uds</span></a></span><span>
</span><span id="line-1127"></span><span>             </span><span id="local-6989586621680967074"><span class="annot"><span class="annottext">all_uds :: UsageDetails
</span><a href="#local-6989586621680967074"><span class="hs-identifier hs-var hs-var">all_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680967077"><span class="hs-identifier hs-var">flt_binds</span></a></span><span> </span><span class="annot"><span class="annottext">[DictBind] -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#addDictBinds"><span class="hs-operator hs-var">`addDictBinds`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967076"><span class="hs-identifier hs-var">free_uds</span></a></span><span>
</span><span id="line-1128"></span><span>             </span><span id="local-6989586621680967072"><span class="annot"><span class="annottext">alt' :: Alt Id
</span><a href="#local-6989586621680967072"><span class="hs-identifier hs-var hs-var">alt'</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680967117"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967102"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Specialise.html#wrapDictBindsE"><span class="hs-identifier hs-var">wrapDictBindsE</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967075"><span class="hs-identifier hs-var">dumped_dbs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967089"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1129"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, Id, [Alt Id], UsageDetails)
-&gt; SpecM (CoreExpr, Id, [Alt Id], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967110"><span class="hs-identifier hs-var">case_bndr_flt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967106"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Alt Id
</span><a href="#local-6989586621680967072"><span class="hs-identifier hs-var">alt'</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967074"><span class="hs-identifier hs-var">all_uds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1130"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1131"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680967092"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967092"><span class="hs-identifier hs-var">env_rhs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967106"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967106"><span class="hs-identifier hs-var">case_bndr'</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680967102"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967102"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; [Id] -&gt; (SpecEnv, [Id])
</span><a href="GHC.Core.Opt.Specialise.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967120"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967118"><span class="hs-identifier hs-var">case_bndr</span></a></span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967116"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1132"></span><span>    </span><span id="local-6989586621680967111"><span class="annot"><span class="annottext">sc_args' :: [Id]
</span><a href="#local-6989586621680967111"><span class="hs-identifier hs-var hs-var">sc_args'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; [Id]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680967071"><span class="hs-identifier hs-var">is_flt_sc_arg</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967102"><span class="hs-identifier hs-var">args'</span></a></span><span>
</span><span id="line-1133"></span><span>
</span><span id="line-1134"></span><span>    </span><span id="local-6989586621680967107"><span class="annot"><span class="annottext">clone_me :: Id -&gt; m Id
</span><a href="#local-6989586621680967107"><span class="hs-identifier hs-var hs-var">clone_me</span></a></span></span><span> </span><span id="local-6989586621680967064"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967064"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680967063"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680967063"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">m Unique
forall (m :: * -&gt; *). MonadUnique m =&gt; m Unique
</span><a href="GHC.Types.Unique.Supply.html#getUniqueM"><span class="hs-identifier hs-var">getUniqueM</span></a></span><span>
</span><span id="line-1135"></span><span>                       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; m Id
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; Unique -&gt; Type -&gt; Type -&gt; SrcSpan -&gt; Id
</span><a href="GHC.Types.Id.html#mkUserLocalOrCoVar"><span class="hs-identifier hs-var">mkUserLocalOrCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621680967060"><span class="hs-identifier hs-var">occ</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680967063"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680967059"><span class="hs-identifier hs-var">wght</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680967058"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621680967057"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1136"></span><span>       </span><span class="hs-keyword">where</span><span>
</span><span id="line-1137"></span><span>         </span><span id="local-6989586621680967056"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621680967056"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967064"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1138"></span><span>         </span><span id="local-6989586621680967059"><span class="annot"><span class="annottext">wght :: Type
</span><a href="#local-6989586621680967059"><span class="hs-identifier hs-var hs-var">wght</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idMult"><span class="hs-identifier hs-var">idMult</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967064"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1139"></span><span>         </span><span id="local-6989586621680967058"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621680967058"><span class="hs-identifier hs-var hs-var">ty</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967064"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1140"></span><span>         </span><span id="local-6989586621680967060"><span class="annot"><span class="annottext">occ :: OccName
</span><a href="#local-6989586621680967060"><span class="hs-identifier hs-var hs-var">occ</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680967056"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1141"></span><span>         </span><span id="local-6989586621680967057"><span class="annot"><span class="annottext">loc :: SrcSpan
</span><a href="#local-6989586621680967057"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680967056"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1142"></span><span>
</span><span id="line-1143"></span><span>    </span><span id="local-6989586621680967050"><span class="annot"><span class="annottext">arg_set :: VarSet
</span><a href="#local-6989586621680967050"><span class="hs-identifier hs-var hs-var">arg_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967102"><span class="hs-identifier hs-var">args'</span></a></span><span>
</span><span id="line-1144"></span><span>    </span><span id="local-6989586621680967071"><span class="annot"><span class="annottext">is_flt_sc_arg :: Id -&gt; Bool
</span><a href="#local-6989586621680967071"><span class="hs-identifier hs-var hs-var">is_flt_sc_arg</span></a></span></span><span> </span><span id="local-6989586621680967049"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967049"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967049"><span class="hs-identifier hs-var">var</span></a></span><span>
</span><span id="line-1145"></span><span>                      </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isDeadBinder"><span class="hs-identifier hs-var">isDeadBinder</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967049"><span class="hs-identifier hs-var">var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1146"></span><span>                      </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isDictTy"><span class="hs-identifier hs-var">isDictTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680967046"><span class="hs-identifier hs-var">var_ty</span></a></span><span>
</span><span id="line-1147"></span><span>                      </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680967046"><span class="hs-identifier hs-var">var_ty</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#disjointVarSet"><span class="hs-operator hs-var">`disjointVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680967050"><span class="hs-identifier hs-var">arg_set</span></a></span><span>
</span><span id="line-1148"></span><span>       </span><span class="hs-keyword">where</span><span>
</span><span id="line-1149"></span><span>         </span><span id="local-6989586621680967046"><span class="annot"><span class="annottext">var_ty :: Type
</span><a href="#local-6989586621680967046"><span class="hs-identifier hs-var hs-var">var_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967049"><span class="hs-identifier hs-var">var</span></a></span><span>
</span><span id="line-1150"></span><span>
</span><span id="line-1151"></span><span>
</span><span id="line-1152"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specCase"><span class="hs-identifier hs-var">specCase</span></a></span><span> </span><span id="local-6989586621680967043"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967043"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680967042"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967042"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680967041"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967041"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span id="local-6989586621680967040"><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680967040"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-1153"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967039"><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680967039"><span class="hs-identifier hs-var">alts'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967038"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967038"><span class="hs-identifier hs-var">uds_alts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Alt Id -&gt; SpecM (Alt Id, UsageDetails))
-&gt; [Alt Id] -&gt; SpecM ([Alt Id], UsageDetails)
forall a b.
(a -&gt; SpecM (b, UsageDetails)) -&gt; [a] -&gt; SpecM ([b], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#mapAndCombineSM"><span class="hs-identifier hs-var">mapAndCombineSM</span></a></span><span> </span><span class="annot"><span class="annottext">Alt Id -&gt; SpecM (Alt Id, UsageDetails)
forall {a}.
(a, [Id], CoreExpr) -&gt; SpecM ((a, [Id], CoreExpr), UsageDetails)
</span><a href="#local-6989586621680967036"><span class="hs-identifier hs-var">spec_alt</span></a></span><span> </span><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680967040"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-1154"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, Id, [Alt Id], UsageDetails)
-&gt; SpecM (CoreExpr, Id, [Alt Id], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967042"><span class="hs-identifier hs-var">scrut</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967035"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680967039"><span class="hs-identifier hs-var">alts'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967038"><span class="hs-identifier hs-var">uds_alts</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1155"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1156"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680967034"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967034"><span class="hs-identifier hs-var">env_alt</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967035"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967035"><span class="hs-identifier hs-var">case_bndr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; Id -&gt; (SpecEnv, Id)
</span><a href="GHC.Core.Opt.Specialise.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967043"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967041"><span class="hs-identifier hs-var">case_bndr</span></a></span><span>
</span><span id="line-1157"></span><span>    </span><span id="local-6989586621680967036"><span class="annot"><span class="annottext">spec_alt :: (a, [Id], CoreExpr) -&gt; SpecM ((a, [Id], CoreExpr), UsageDetails)
</span><a href="#local-6989586621680967036"><span class="hs-identifier hs-var hs-var">spec_alt</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967030"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680967030"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967029"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967029"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967028"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967028"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1158"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621680967027"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967027"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967026"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967026"><span class="hs-identifier hs-var">uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967025"><span class="hs-identifier hs-var">env_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967028"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1159"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967024"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967024"><span class="hs-identifier hs-var">free_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967023"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967023"><span class="hs-identifier hs-var">dumped_dbs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; UsageDetails -&gt; (UsageDetails, Bag DictBind)
</span><a href="GHC.Core.Opt.Specialise.html#dumpUDs"><span class="hs-identifier hs-var">dumpUDs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967035"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967022"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967026"><span class="hs-identifier hs-var">uds</span></a></span><span>
</span><span id="line-1160"></span><span>          </span><span class="annot"><span class="annottext">((a, [Id], CoreExpr), UsageDetails)
-&gt; SpecM ((a, [Id], CoreExpr), UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680967030"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967022"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Specialise.html#wrapDictBindsE"><span class="hs-identifier hs-var">wrapDictBindsE</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967023"><span class="hs-identifier hs-var">dumped_dbs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967027"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967024"><span class="hs-identifier hs-var">free_uds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1161"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-1162"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621680967025"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967025"><span class="hs-identifier hs-var">env_rhs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967022"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967022"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; [Id] -&gt; (SpecEnv, [Id])
</span><a href="GHC.Core.Opt.Specialise.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967034"><span class="hs-identifier hs-var">env_alt</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680967029"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1163"></span><span>
</span><span id="line-1164"></span><span class="hs-comment">{-
Note [Floating dictionaries out of cases]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
   g = \d. case d of { MkD sc ... -&gt; ...(f sc)... }
Naively we can't float d2's binding out of the case expression,
because 'sc' is bound by the case, and that in turn means we can't
specialise f, which seems a pity.

So we invert the case, by floating out a binding
for 'sc_flt' thus:
    sc_flt = case d of { MkD sc ... -&gt; sc }
Now we can float the call instance for 'f'.  Indeed this is just
what'll happen if 'sc' was originally bound with a let binding,
but case is more efficient, and necessary with equalities. So it's
good to work with both.

You might think that this won't make any difference, because the
call instance will only get nuked by the \d.  BUT if 'g' itself is
specialised, then transitively we should be able to specialise f.

In general, given
   case e of cb { MkD sc ... -&gt; ...(f sc)... }
we transform to
   let cb_flt = e
       sc_flt = case cb_flt of { MkD sc ... -&gt; sc }
   in
   case cb_flt of bg { MkD sc ... -&gt; ....(f sc_flt)... }

The &quot;_flt&quot; things are the floated binds; we use the current substitution
to substitute sc -&gt; sc_flt in the RHS

************************************************************************
*                                                                      *
                     Dealing with a binding
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1202"></span><span>
</span><span id="line-1203"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specBind"><span class="hs-identifier hs-type">specBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>                     </span><span class="hs-comment">-- Use this for RHSs</span><span>
</span><span id="line-1204"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span>                    </span><span class="hs-comment">-- Binders are already cloned by cloneBindSM,</span><span>
</span><span id="line-1205"></span><span>                                        </span><span class="hs-comment">-- but RHSs are un-processed</span><span>
</span><span id="line-1206"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>                </span><span class="hs-comment">-- Info on how the scope of the binding</span><span>
</span><span id="line-1207"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span>          </span><span class="hs-comment">-- New bindings</span><span>
</span><span id="line-1208"></span><span>                   </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">)</span><span>        </span><span class="hs-comment">-- And info to pass upstream</span><span>
</span><span id="line-1209"></span><span>
</span><span id="line-1210"></span><span class="hs-comment">-- Returned UsageDetails:</span><span>
</span><span id="line-1211"></span><span class="hs-comment">--    No calls for binders of this bind</span><span>
</span><span id="line-1212"></span><span id="specBind"><span class="annot"><span class="annottext">specBind :: SpecEnv
-&gt; CoreBind -&gt; UsageDetails -&gt; SpecM (CoreProgram, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specBind"><span class="hs-identifier hs-var hs-var">specBind</span></a></span></span><span> </span><span id="local-6989586621680967021"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967021"><span class="hs-identifier hs-var">rhs_env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680967020"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967020"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621680967019"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967019"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680967018"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967018"><span class="hs-identifier hs-var">body_uds</span></a></span></span><span>
</span><span id="line-1213"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967017"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967017"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967016"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967016"><span class="hs-identifier hs-var">rhs_uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967021"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967019"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1214"></span><span>
</span><span id="line-1215"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680967015"><span class="annot"><span class="annottext">zapped_fn :: Id
</span><a href="#local-6989586621680967015"><span class="hs-identifier hs-var hs-var">zapped_fn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="GHC.Types.Id.html#zapIdDemandInfo"><span class="hs-identifier hs-var">zapIdDemandInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967020"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-1216"></span><span>              </span><span class="hs-comment">-- We zap the demand info because the binding may float,</span><span>
</span><span id="line-1217"></span><span>              </span><span class="hs-comment">-- which would invaidate the demand info (see #17810 for example).</span><span>
</span><span id="line-1218"></span><span>              </span><span class="hs-comment">-- Destroying demand info is not terrible; specialisation is</span><span>
</span><span id="line-1219"></span><span>              </span><span class="hs-comment">-- always followed soon by demand analysis.</span><span>
</span><span id="line-1220"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967013"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967013"><span class="hs-identifier hs-var">fn'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967012"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680967012"><span class="hs-identifier hs-var">spec_defns</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967011"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967011"><span class="hs-identifier hs-var">body_uds1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; UsageDetails
-&gt; Id
-&gt; CoreExpr
-&gt; SpecM (Id, [(Id, CoreExpr)], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specDefn"><span class="hs-identifier hs-var">specDefn</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680967021"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967018"><span class="hs-identifier hs-var">body_uds</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967015"><span class="hs-identifier hs-var">zapped_fn</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967019"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1221"></span><span>
</span><span id="line-1222"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680967009"><span class="annot"><span class="annottext">pairs :: [(Id, CoreExpr)]
</span><a href="#local-6989586621680967009"><span class="hs-identifier hs-var hs-var">pairs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680967012"><span class="hs-identifier hs-var">spec_defns</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; [(Id, CoreExpr)] -&gt; [(Id, CoreExpr)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967013"><span class="hs-identifier hs-var">fn'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680967017"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-1223"></span><span>                        </span><span class="hs-comment">-- fn' mentions the spec_defns in its rules,</span><span>
</span><span id="line-1224"></span><span>                        </span><span class="hs-comment">-- so put the latter first</span><span>
</span><span id="line-1225"></span><span>
</span><span id="line-1226"></span><span>             </span><span id="local-6989586621680967008"><span class="annot"><span class="annottext">combined_uds :: UsageDetails
</span><a href="#local-6989586621680967008"><span class="hs-identifier hs-var hs-var">combined_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967011"><span class="hs-identifier hs-var">body_uds1</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#plusUDs"><span class="hs-operator hs-var">`plusUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967016"><span class="hs-identifier hs-var">rhs_uds</span></a></span><span>
</span><span id="line-1227"></span><span>
</span><span id="line-1228"></span><span>             </span><span class="hs-special">(</span><span id="local-6989586621680967007"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967007"><span class="hs-identifier hs-var">free_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967006"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967006"><span class="hs-identifier hs-var">dump_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680967005"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680967005"><span class="hs-identifier hs-var">float_all</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; UsageDetails -&gt; (UsageDetails, Bag DictBind, Bool)
</span><a href="GHC.Core.Opt.Specialise.html#dumpBindUDs"><span class="hs-identifier hs-var">dumpBindUDs</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967020"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967008"><span class="hs-identifier hs-var">combined_uds</span></a></span><span>
</span><span id="line-1229"></span><span>
</span><span id="line-1230"></span><span>             </span><span class="annot"><a href="#local-6989586621680967003"><span class="hs-identifier hs-type">final_binds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1231"></span><span>             </span><span class="hs-comment">-- See Note [From non-recursive to recursive]</span><span>
</span><span id="line-1232"></span><span>             </span><span id="local-6989586621680967003"><span class="annot"><span class="annottext">final_binds :: [DictBind]
</span><a href="#local-6989586621680967003"><span class="hs-identifier hs-var hs-var">final_binds</span></a></span></span><span>
</span><span id="line-1233"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag DictBind -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967006"><span class="hs-identifier hs-var">dump_dbs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1234"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680967012"><span class="hs-identifier hs-var">spec_defns</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1235"></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; Bag DictBind -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#recWithDumpedDicts"><span class="hs-identifier hs-var">recWithDumpedDicts</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680967009"><span class="hs-identifier hs-var">pairs</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967006"><span class="hs-identifier hs-var">dump_dbs</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1236"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1237"></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CoreBind -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#mkDB"><span class="hs-identifier hs-var">mkDB</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBind -&gt; DictBind) -&gt; CoreBind -&gt; DictBind
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967000"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966999"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680967000"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680967000"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680966999"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966999"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680967009"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1238"></span><span>                 </span><span class="annot"><span class="annottext">[DictBind] -&gt; [DictBind] -&gt; [DictBind]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; [DictBind]
forall a. Bag a -&gt; [a]
</span><a href="GHC.Data.Bag.html#bagToList"><span class="hs-identifier hs-var">bagToList</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680967006"><span class="hs-identifier hs-var">dump_dbs</span></a></span><span>
</span><span id="line-1239"></span><span>
</span><span id="line-1240"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680967005"><span class="hs-identifier hs-var">float_all</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-1241"></span><span>             </span><span class="hs-comment">-- Rather than discard the calls mentioning the bound variables</span><span>
</span><span id="line-1242"></span><span>             </span><span class="hs-comment">-- we float this (dictionary) binding along with the others</span><span>
</span><span id="line-1243"></span><span>              </span><span class="annot"><span class="annottext">(CoreProgram, UsageDetails) -&gt; SpecM (CoreProgram, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967007"><span class="hs-identifier hs-var">free_uds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; [DictBind] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#snocDictBinds"><span class="hs-operator hs-var">`snocDictBinds`</span></a></span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680967003"><span class="hs-identifier hs-var">final_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1244"></span><span>         </span><span class="hs-keyword">else</span><span>
</span><span id="line-1245"></span><span>             </span><span class="hs-comment">-- No call in final_uds mentions bound variables,</span><span>
</span><span id="line-1246"></span><span>             </span><span class="hs-comment">-- so we can just leave the binding here</span><span>
</span><span id="line-1247"></span><span>              </span><span class="annot"><span class="annottext">(CoreProgram, UsageDetails) -&gt; SpecM (CoreProgram, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(DictBind -&gt; CoreBind) -&gt; [DictBind] -&gt; CoreProgram
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind -&gt; CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var hs-var">db_bind</span></a></span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680967003"><span class="hs-identifier hs-var">final_binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680967007"><span class="hs-identifier hs-var">free_uds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1248"></span><span>
</span><span id="line-1249"></span><span>
</span><span id="line-1250"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specBind"><span class="hs-identifier hs-var">specBind</span></a></span><span> </span><span id="local-6989586621680966996"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966996"><span class="hs-identifier hs-var">rhs_env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680966995"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966995"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680966994"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966994"><span class="hs-identifier hs-var">body_uds</span></a></span></span><span>
</span><span id="line-1251"></span><span>       </span><span class="hs-comment">-- Note [Specialising a recursive group]</span><span>
</span><span id="line-1252"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966993"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966993"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680966992"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966992"><span class="hs-identifier hs-var">rhss</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; ([Id], [CoreExpr])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966995"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-1253"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966990"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966990"><span class="hs-identifier hs-var">rhss'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966989"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966989"><span class="hs-identifier hs-var">rhs_uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; SpecM (CoreExpr, UsageDetails))
-&gt; [CoreExpr] -&gt; SpecM ([CoreExpr], UsageDetails)
forall a b.
(a -&gt; SpecM (b, UsageDetails)) -&gt; [a] -&gt; SpecM ([b], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#mapAndCombineSM"><span class="hs-identifier hs-var">mapAndCombineSM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specExpr"><span class="hs-identifier hs-var">specExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966996"><span class="hs-identifier hs-var">rhs_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966992"><span class="hs-identifier hs-var">rhss</span></a></span><span>
</span><span id="line-1254"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680966988"><span class="annot"><span class="annottext">scope_uds :: UsageDetails
</span><a href="#local-6989586621680966988"><span class="hs-identifier hs-var hs-var">scope_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966994"><span class="hs-identifier hs-var">body_uds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#plusUDs"><span class="hs-operator hs-var">`plusUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966989"><span class="hs-identifier hs-var">rhs_uds</span></a></span><span>
</span><span id="line-1255"></span><span>                       </span><span class="hs-comment">-- Includes binds and calls arising from rhss</span><span>
</span><span id="line-1256"></span><span>
</span><span id="line-1257"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966987"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966987"><span class="hs-identifier hs-var">bndrs1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966986"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966986"><span class="hs-identifier hs-var">spec_defns1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966985"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966985"><span class="hs-identifier hs-var">uds1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; UsageDetails
-&gt; [(Id, CoreExpr)]
-&gt; SpecM ([Id], [(Id, CoreExpr)], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specDefns"><span class="hs-identifier hs-var">specDefns</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966996"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966988"><span class="hs-identifier hs-var">scope_uds</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966995"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-1258"></span><span>
</span><span id="line-1259"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966983"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966983"><span class="hs-identifier hs-var">bndrs3</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966982"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966982"><span class="hs-identifier hs-var">spec_defns3</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966981"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966981"><span class="hs-identifier hs-var">uds3</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1260"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966986"><span class="hs-identifier hs-var">spec_defns1</span></a></span><span>  </span><span class="hs-comment">-- Common case: no specialisation</span><span>
</span><span id="line-1261"></span><span>                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">([Id], [(Id, CoreExpr)], UsageDetails)
-&gt; SpecM ([Id], [(Id, CoreExpr)], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966987"><span class="hs-identifier hs-var">bndrs1</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966985"><span class="hs-identifier hs-var">uds1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1262"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>            </span><span class="hs-comment">-- Specialisation occurred; do it again</span><span>
</span><span id="line-1263"></span><span>                          </span><span class="hs-special">(</span><span id="local-6989586621680966980"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966980"><span class="hs-identifier hs-var">bndrs2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966979"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966979"><span class="hs-identifier hs-var">spec_defns2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966978"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966978"><span class="hs-identifier hs-var">uds2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1264"></span><span>                              </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; UsageDetails
-&gt; [(Id, CoreExpr)]
-&gt; SpecM ([Id], [(Id, CoreExpr)], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specDefns"><span class="hs-identifier hs-var">specDefns</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966996"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966985"><span class="hs-identifier hs-var">uds1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966987"><span class="hs-identifier hs-var">bndrs1</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [CoreExpr] -&gt; [(Id, CoreExpr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966992"><span class="hs-identifier hs-var">rhss</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1265"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Id], [(Id, CoreExpr)], UsageDetails)
-&gt; SpecM ([Id], [(Id, CoreExpr)], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966980"><span class="hs-identifier hs-var">bndrs2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966979"><span class="hs-identifier hs-var">spec_defns2</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; [(Id, CoreExpr)] -&gt; [(Id, CoreExpr)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966986"><span class="hs-identifier hs-var">spec_defns1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966978"><span class="hs-identifier hs-var">uds2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1266"></span><span>
</span><span id="line-1267"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966977"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966977"><span class="hs-identifier hs-var">final_uds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966976"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966976"><span class="hs-identifier hs-var">dumped_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966975"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966975"><span class="hs-identifier hs-var">float_all</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; UsageDetails -&gt; (UsageDetails, Bag DictBind, Bool)
</span><a href="GHC.Core.Opt.Specialise.html#dumpBindUDs"><span class="hs-identifier hs-var">dumpBindUDs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966993"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966981"><span class="hs-identifier hs-var">uds3</span></a></span><span>
</span><span id="line-1268"></span><span>             </span><span id="local-6989586621680966974"><span class="annot"><span class="annottext">final_bind :: DictBind
</span><a href="#local-6989586621680966974"><span class="hs-identifier hs-var hs-var">final_bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; Bag DictBind -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#recWithDumpedDicts"><span class="hs-identifier hs-var">recWithDumpedDicts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966982"><span class="hs-identifier hs-var">spec_defns3</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; [(Id, CoreExpr)] -&gt; [(Id, CoreExpr)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [CoreExpr] -&gt; [(Id, CoreExpr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966983"><span class="hs-identifier hs-var">bndrs3</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966990"><span class="hs-identifier hs-var">rhss'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1269"></span><span>                                             </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966976"><span class="hs-identifier hs-var">dumped_dbs</span></a></span><span>
</span><span id="line-1270"></span><span>
</span><span id="line-1271"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966975"><span class="hs-identifier hs-var">float_all</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-1272"></span><span>              </span><span class="annot"><span class="annottext">(CoreProgram, UsageDetails) -&gt; SpecM (CoreProgram, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966977"><span class="hs-identifier hs-var">final_uds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; DictBind -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#snocDictBind"><span class="hs-operator hs-var">`snocDictBind`</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966974"><span class="hs-identifier hs-var">final_bind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1273"></span><span>         </span><span class="hs-keyword">else</span><span>
</span><span id="line-1274"></span><span>              </span><span class="annot"><span class="annottext">(CoreProgram, UsageDetails) -&gt; SpecM (CoreProgram, UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><span class="annottext">DictBind -&gt; CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var hs-var">db_bind</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966974"><span class="hs-identifier hs-var">final_bind</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966977"><span class="hs-identifier hs-var">final_uds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1275"></span><span>
</span><span id="line-1276"></span><span>
</span><span id="line-1277"></span><span class="hs-comment">---------------------------</span><span>
</span><span id="line-1278"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specDefns"><span class="hs-identifier hs-type">specDefns</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>
</span><span id="line-1279"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>               </span><span class="hs-comment">-- Info on how it is used in its scope</span><span>
</span><span id="line-1280"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>           </span><span class="hs-comment">-- The things being bound and their un-processed RHS</span><span>
</span><span id="line-1281"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span>            </span><span class="hs-comment">-- Original Ids with RULES added</span><span>
</span><span id="line-1282"></span><span>                    </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span>  </span><span class="hs-comment">-- Extra, specialised bindings</span><span>
</span><span id="line-1283"></span><span>                    </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">)</span><span>       </span><span class="hs-comment">-- Stuff to fling upwards from the specialised versions</span><span>
</span><span id="line-1284"></span><span>
</span><span id="line-1285"></span><span class="hs-comment">-- Specialise a list of bindings (the contents of a Rec), but flowing usages</span><span>
</span><span id="line-1286"></span><span class="hs-comment">-- upwards binding by binding.  Example: { f = ...g ...; g = ...f .... }</span><span>
</span><span id="line-1287"></span><span class="hs-comment">-- Then if the input CallDetails has a specialised call for 'g', whose specialisation</span><span>
</span><span id="line-1288"></span><span class="hs-comment">-- in turn generates a specialised call for 'f', we catch that in this one sweep.</span><span>
</span><span id="line-1289"></span><span class="hs-comment">-- But not vice versa (it's a fixpoint problem).</span><span>
</span><span id="line-1290"></span><span>
</span><span id="line-1291"></span><span id="specDefns"><span class="annot"><span class="annottext">specDefns :: SpecEnv
-&gt; UsageDetails
-&gt; [(Id, CoreExpr)]
-&gt; SpecM ([Id], [(Id, CoreExpr)], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specDefns"><span class="hs-identifier hs-var hs-var">specDefns</span></a></span></span><span> </span><span id="local-6989586621680966971"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966971"><span class="hs-identifier hs-var">_env</span></a></span></span><span> </span><span id="local-6989586621680966970"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966970"><span class="hs-identifier hs-var">uds</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1292"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Id], [(Id, CoreExpr)], UsageDetails)
-&gt; SpecM ([Id], [(Id, CoreExpr)], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966970"><span class="hs-identifier hs-var">uds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1293"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specDefns"><span class="hs-identifier hs-var">specDefns</span></a></span><span> </span><span id="local-6989586621680966969"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966969"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966968"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966968"><span class="hs-identifier hs-var">uds</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621680966967"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966967"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680966966"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966966"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680966965"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966965"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1294"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966964"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966964"><span class="hs-identifier hs-var">bndrs1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966963"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966963"><span class="hs-identifier hs-var">spec_defns1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966962"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966962"><span class="hs-identifier hs-var">uds1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; UsageDetails
-&gt; [(Id, CoreExpr)]
-&gt; SpecM ([Id], [(Id, CoreExpr)], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specDefns"><span class="hs-identifier hs-var">specDefns</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966969"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966968"><span class="hs-identifier hs-var">uds</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966965"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-1295"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966961"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966961"><span class="hs-identifier hs-var">bndr1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966960"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966960"><span class="hs-identifier hs-var">spec_defns2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966959"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966959"><span class="hs-identifier hs-var">uds2</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; UsageDetails
-&gt; Id
-&gt; CoreExpr
-&gt; SpecM (Id, [(Id, CoreExpr)], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specDefn"><span class="hs-identifier hs-var">specDefn</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966969"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966962"><span class="hs-identifier hs-var">uds1</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966967"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966966"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1296"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Id], [(Id, CoreExpr)], UsageDetails)
-&gt; SpecM ([Id], [(Id, CoreExpr)], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966961"><span class="hs-identifier hs-var">bndr1</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966964"><span class="hs-identifier hs-var">bndrs1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966963"><span class="hs-identifier hs-var">spec_defns1</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; [(Id, CoreExpr)] -&gt; [(Id, CoreExpr)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966960"><span class="hs-identifier hs-var">spec_defns2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966959"><span class="hs-identifier hs-var">uds2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1297"></span><span>
</span><span id="line-1298"></span><span class="hs-comment">---------------------------</span><span>
</span><span id="line-1299"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specDefn"><span class="hs-identifier hs-type">specDefn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>
</span><span id="line-1300"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>                </span><span class="hs-comment">-- Info on how it is used in its scope</span><span>
</span><span id="line-1301"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span>             </span><span class="hs-comment">-- The thing being bound and its un-processed RHS</span><span>
</span><span id="line-1302"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span>                  </span><span class="hs-comment">-- Original Id with added RULES</span><span>
</span><span id="line-1303"></span><span>                   </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span>     </span><span class="hs-comment">-- Extra, specialised bindings</span><span>
</span><span id="line-1304"></span><span>                   </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">)</span><span>        </span><span class="hs-comment">-- Stuff to fling upwards from the specialised versions</span><span>
</span><span id="line-1305"></span><span>
</span><span id="line-1306"></span><span id="specDefn"><span class="annot"><span class="annottext">specDefn :: SpecEnv
-&gt; UsageDetails
-&gt; Id
-&gt; CoreExpr
-&gt; SpecM (Id, [(Id, CoreExpr)], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specDefn"><span class="hs-identifier hs-var hs-var">specDefn</span></a></span></span><span> </span><span id="local-6989586621680966958"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966958"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966957"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966957"><span class="hs-identifier hs-var">body_uds</span></a></span></span><span> </span><span id="local-6989586621680966956"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966956"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621680966955"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966955"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-1307"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966954"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966954"><span class="hs-identifier hs-var">body_uds_without_me</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966953"><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680966953"><span class="hs-identifier hs-var">calls_for_me</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; UsageDetails -&gt; (UsageDetails, [CallInfo])
</span><a href="GHC.Core.Opt.Specialise.html#callsForMe"><span class="hs-identifier hs-var">callsForMe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966956"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966957"><span class="hs-identifier hs-var">body_uds</span></a></span><span>
</span><span id="line-1308"></span><span>             </span><span id="local-6989586621680966951"><span class="annot"><span class="annottext">rules_for_me :: [CoreRule]
</span><a href="#local-6989586621680966951"><span class="hs-identifier hs-var hs-var">rules_for_me</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [CoreRule]
</span><a href="GHC.Types.Id.html#idCoreRules"><span class="hs-identifier hs-var">idCoreRules</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966956"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-1309"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966949"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680966949"><span class="hs-identifier hs-var">rules</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966948"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966948"><span class="hs-identifier hs-var">spec_defns</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966947"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966947"><span class="hs-identifier hs-var">spec_uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe Module
-&gt; SpecEnv
-&gt; [CoreRule]
-&gt; [CallInfo]
-&gt; Id
-&gt; CoreExpr
-&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specCalls"><span class="hs-identifier hs-var">specCalls</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Module
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966958"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680966951"><span class="hs-identifier hs-var">rules_for_me</span></a></span><span>
</span><span id="line-1310"></span><span>                                                    </span><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680966953"><span class="hs-identifier hs-var">calls_for_me</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966956"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966955"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1311"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Id, [(Id, CoreExpr)], UsageDetails)
-&gt; SpecM (Id, [(Id, CoreExpr)], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966956"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [CoreRule] -&gt; Id
</span><a href="GHC.Core.Rules.html#addIdSpecialisations"><span class="hs-operator hs-var">`addIdSpecialisations`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680966949"><span class="hs-identifier hs-var">rules</span></a></span><span>
</span><span id="line-1312"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966948"><span class="hs-identifier hs-var">spec_defns</span></a></span><span>
</span><span id="line-1313"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966954"><span class="hs-identifier hs-var">body_uds_without_me</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#plusUDs"><span class="hs-operator hs-var">`plusUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966947"><span class="hs-identifier hs-var">spec_uds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1314"></span><span>                </span><span class="hs-comment">-- It's important that the `plusUDs` is this way</span><span>
</span><span id="line-1315"></span><span>                </span><span class="hs-comment">-- round, because body_uds_without_me may bind</span><span>
</span><span id="line-1316"></span><span>                </span><span class="hs-comment">-- dictionaries that are used in calls_for_me passed</span><span>
</span><span id="line-1317"></span><span>                </span><span class="hs-comment">-- to specDefn.  So the dictionary bindings in</span><span>
</span><span id="line-1318"></span><span>                </span><span class="hs-comment">-- spec_uds may mention dictionaries bound in</span><span>
</span><span id="line-1319"></span><span>                </span><span class="hs-comment">-- body_uds_without_me</span><span>
</span><span id="line-1320"></span><span>
</span><span id="line-1321"></span><span class="hs-comment">---------------------------</span><span>
</span><span id="line-1322"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specCalls"><span class="hs-identifier hs-type">specCalls</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier hs-type">Module</span></a></span><span>      </span><span class="hs-comment">-- Just this_mod  =&gt;  specialising imported fn</span><span>
</span><span id="line-1323"></span><span>                               </span><span class="hs-comment">-- Nothing        =&gt;  specialising local fn</span><span>
</span><span id="line-1324"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>
</span><span id="line-1325"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span>        </span><span class="hs-comment">-- Existing RULES for the fn</span><span>
</span><span id="line-1326"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfo"><span class="hs-identifier hs-type">CallInfo</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1327"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span>
</span><span id="line-1328"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecInfo"><span class="hs-identifier hs-type">SpecInfo</span></a></span><span>    </span><span class="hs-comment">-- New rules, specialised bindings, and usage details</span><span>
</span><span id="line-1329"></span><span>
</span><span id="line-1330"></span><span class="hs-comment">-- This function checks existing rules, and does not create</span><span>
</span><span id="line-1331"></span><span class="hs-comment">-- duplicate ones. So the caller does not need to do this filtering.</span><span>
</span><span id="line-1332"></span><span class="hs-comment">-- See 'already_covered'</span><span>
</span><span id="line-1333"></span><span>
</span><span id="line-1334"></span><span class="hs-keyword">type</span><span> </span><span id="SpecInfo"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecInfo"><span class="hs-identifier hs-var">SpecInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span>       </span><span class="hs-comment">-- Specialisation rules</span><span>
</span><span id="line-1335"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- Specialised definition</span><span>
</span><span id="line-1336"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- Usage details from specialised RHSs</span><span>
</span><span id="line-1337"></span><span>
</span><span id="line-1338"></span><span id="specCalls"><span class="annot"><span class="annottext">specCalls :: Maybe Module
-&gt; SpecEnv
-&gt; [CoreRule]
-&gt; [CallInfo]
-&gt; Id
-&gt; CoreExpr
-&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specCalls"><span class="hs-identifier hs-var hs-var">specCalls</span></a></span></span><span> </span><span id="local-6989586621680966944"><span class="annot"><span class="annottext">Maybe Module
</span><a href="#local-6989586621680966944"><span class="hs-identifier hs-var">mb_mod</span></a></span></span><span> </span><span id="local-6989586621680966943"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966943"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966942"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680966942"><span class="hs-identifier hs-var">existing_rules</span></a></span></span><span> </span><span id="local-6989586621680966941"><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680966941"><span class="hs-identifier hs-var">calls_for_me</span></a></span></span><span> </span><span id="local-6989586621680966940"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621680966939"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966939"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-1339"></span><span>        </span><span class="hs-comment">-- The first case is the interesting one</span><span>
</span><span id="line-1340"></span><span>  </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">[CallInfo] -&gt; Bool
forall a. [a] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#notNull"><span class="hs-identifier hs-var">notNull</span></a></span><span> </span><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680966941"><span class="hs-identifier hs-var">calls_for_me</span></a></span><span>               </span><span class="hs-comment">-- And there are some calls to specialise</span><span>
</span><span id="line-1341"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Activation -&gt; Bool
</span><a href="GHC.Types.Basic.html#isNeverActive"><span class="hs-identifier hs-var">isNeverActive</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Activation
</span><a href="GHC.Types.Id.html#idInlineActivation"><span class="hs-identifier hs-var">idInlineActivation</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1342"></span><span>        </span><span class="hs-comment">-- Don't specialise NOINLINE things</span><span>
</span><span id="line-1343"></span><span>        </span><span class="hs-comment">-- See Note [Auto-specialisation and RULES]</span><span>
</span><span id="line-1344"></span><span>
</span><span id="line-1345"></span><span class="hs-comment">--   &amp;&amp; not (certainlyWillInline (idUnfolding fn))      -- And it's not small</span><span>
</span><span id="line-1346"></span><span class="hs-comment">--      See Note [Inline specialisation] for why we do not</span><span>
</span><span id="line-1347"></span><span class="hs-comment">--      switch off specialisation for inline functions</span><span>
</span><span id="line-1348"></span><span>
</span><span id="line-1349"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;specDefn: some&quot; (ppr fn $$ ppr calls_for_me $$ ppr existing_rules) $</span><span>
</span><span id="line-1350"></span><span>    </span><span class="annot"><span class="annottext">(([CoreRule], [(Id, CoreExpr)], UsageDetails)
 -&gt; CallInfo -&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails))
-&gt; ([CoreRule], [(Id, CoreExpr)], UsageDetails)
-&gt; [CallInfo]
-&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">([CoreRule], [(Id, CoreExpr)], UsageDetails)
-&gt; CallInfo -&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
</span><a href="#local-6989586621680966935"><span class="hs-identifier hs-var">spec_call</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var">emptyUDs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680966941"><span class="hs-identifier hs-var">calls_for_me</span></a></span><span>
</span><span id="line-1351"></span><span>
</span><span id="line-1352"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-comment">-- No calls or RHS doesn't fit our preconceptions</span><span>
</span><span id="line-1353"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">exprIsTrivial</span><span> </span><span class="hs-identifier">rhs</span><span class="hs-special">)</span><span> </span><span class="hs-operator">&amp;&amp;</span><span> </span><span class="hs-identifier">notNull</span><span> </span><span class="hs-identifier">calls_for_me</span><span class="hs-special">,</span><span>
</span><span id="line-1354"></span><span>          </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;Missed specialisation opportunity for&quot;</span><span>
</span><span id="line-1355"></span><span>                                 </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">fn</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">_trace_doc</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1356"></span><span>          </span><span class="hs-comment">-- Note [Specialisation shape]</span><span>
</span><span id="line-1357"></span><span>    </span><span class="hs-comment">-- pprTrace &quot;specDefn: none&quot; (ppr fn &lt;+&gt; ppr calls_for_me) $</span><span>
</span><span id="line-1358"></span><span>    </span><span class="annot"><span class="annottext">([CoreRule], [(Id, CoreExpr)], UsageDetails)
-&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var">emptyUDs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1359"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1360"></span><span>    </span><span id="local-6989586621680966932"><span class="annot"><span class="annottext">_trace_doc :: SDoc
</span><a href="#local-6989586621680966932"><span class="hs-identifier hs-var hs-var">_trace_doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966927"><span class="hs-identifier hs-var">rhs_bndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Activation -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Activation
</span><a href="GHC.Types.Id.html#idInlineActivation"><span class="hs-identifier hs-var">idInlineActivation</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1361"></span><span>
</span><span id="line-1362"></span><span>    </span><span id="local-6989586621680966926"><span class="annot"><span class="annottext">fn_type :: Type
</span><a href="#local-6989586621680966926"><span class="hs-identifier hs-var hs-var">fn_type</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-1363"></span><span>    </span><span id="local-6989586621680966925"><span class="annot"><span class="annottext">fn_arity :: Int
</span><a href="#local-6989586621680966925"><span class="hs-identifier hs-var hs-var">fn_arity</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Int
</span><a href="GHC.Types.Id.html#idArity"><span class="hs-identifier hs-var">idArity</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-1364"></span><span>    </span><span id="local-6989586621680966923"><span class="annot"><span class="annottext">fn_unf :: Unfolding
</span><a href="#local-6989586621680966923"><span class="hs-identifier hs-var hs-var">fn_unf</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Unfolding
</span><a href="GHC.Types.Id.html#realIdUnfolding"><span class="hs-identifier hs-var">realIdUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span>  </span><span class="hs-comment">-- Ignore loop-breaker-ness here</span><span>
</span><span id="line-1365"></span><span>    </span><span id="local-6989586621680966922"><span class="annot"><span class="annottext">inl_prag :: InlinePragma
</span><a href="#local-6989586621680966922"><span class="hs-identifier hs-var hs-var">inl_prag</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; InlinePragma
</span><a href="GHC.Types.Id.html#idInlinePragma"><span class="hs-identifier hs-var">idInlinePragma</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-1366"></span><span>    </span><span id="local-6989586621680966921"><span class="annot"><span class="annottext">inl_act :: Activation
</span><a href="#local-6989586621680966921"><span class="hs-identifier hs-var hs-var">inl_act</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InlinePragma -&gt; Activation
</span><a href="GHC.Types.Basic.html#inlinePragmaActivation"><span class="hs-identifier hs-var">inlinePragmaActivation</span></a></span><span> </span><span class="annot"><span class="annottext">InlinePragma
</span><a href="#local-6989586621680966922"><span class="hs-identifier hs-var">inl_prag</span></a></span><span>
</span><span id="line-1367"></span><span>    </span><span id="local-6989586621680966919"><span class="annot"><span class="annottext">is_local :: Bool
</span><a href="#local-6989586621680966919"><span class="hs-identifier hs-var hs-var">is_local</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isLocalId"><span class="hs-identifier hs-var">isLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-1368"></span><span>    </span><span id="local-6989586621680966917"><span class="annot"><span class="annottext">is_dfun :: Bool
</span><a href="#local-6989586621680966917"><span class="hs-identifier hs-var hs-var">is_dfun</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isDFunId"><span class="hs-identifier hs-var">isDFunId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-1369"></span><span>
</span><span id="line-1370"></span><span>        </span><span class="hs-comment">-- Figure out whether the function has an INLINE pragma</span><span>
</span><span id="line-1371"></span><span>        </span><span class="hs-comment">-- See Note [Inline specialisations]</span><span>
</span><span id="line-1372"></span><span>
</span><span id="line-1373"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680966927"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966927"><span class="hs-identifier hs-var">rhs_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966915"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966915"><span class="hs-identifier hs-var">rhs_body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; ([Id], CoreExpr)
</span><a href="GHC.Core.SimpleOpt.html#collectBindersPushingCo"><span class="hs-identifier hs-var">collectBindersPushingCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966939"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1374"></span><span>                            </span><span class="hs-comment">-- See Note [Account for casts in binding]</span><span>
</span><span id="line-1375"></span><span>
</span><span id="line-1376"></span><span>    </span><span id="local-6989586621680966914"><span class="annot"><span class="annottext">in_scope :: InScopeSet
</span><a href="#local-6989586621680966914"><span class="hs-identifier hs-var hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; InScopeSet
</span><a href="GHC.Core.Subst.html#substInScope"><span class="hs-identifier hs-var">Core.substInScope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var hs-var">se_subst</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966943"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1377"></span><span>
</span><span id="line-1378"></span><span>    </span><span class="annot"><a href="#local-6989586621680966912"><span class="hs-identifier hs-type">already_covered</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#RuleOpts"><span class="hs-identifier hs-type">RuleOpts</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1379"></span><span>    </span><span id="local-6989586621680966912"><span class="annot"><span class="annottext">already_covered :: RuleOpts -&gt; [CoreRule] -&gt; [CoreExpr] -&gt; Bool
</span><a href="#local-6989586621680966912"><span class="hs-identifier hs-var hs-var">already_covered</span></a></span></span><span> </span><span id="local-6989586621680966911"><span class="annot"><span class="annottext">RuleOpts
</span><a href="#local-6989586621680966911"><span class="hs-identifier hs-var">ropts</span></a></span></span><span> </span><span id="local-6989586621680966910"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680966910"><span class="hs-identifier hs-var">new_rules</span></a></span></span><span> </span><span id="local-6989586621680966909"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966909"><span class="hs-identifier hs-var">args</span></a></span></span><span>      </span><span class="hs-comment">-- Note [Specialisations already covered]</span><span>
</span><span id="line-1380"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (CoreRule, CoreExpr) -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RuleOpts
-&gt; InScopeEnv
-&gt; (Activation -&gt; Bool)
-&gt; Id
-&gt; [CoreExpr]
-&gt; [CoreRule]
-&gt; Maybe (CoreRule, CoreExpr)
</span><a href="GHC.Core.Rules.html#lookupRule"><span class="hs-identifier hs-var">lookupRule</span></a></span><span> </span><span class="annot"><span class="annottext">RuleOpts
</span><a href="#local-6989586621680966911"><span class="hs-identifier hs-var">ropts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680966914"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Unfolding
</span><a href="GHC.Types.Id.html#realIdUnfolding"><span class="hs-identifier hs-var">realIdUnfolding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1381"></span><span>                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Activation -&gt; Bool
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966909"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1382"></span><span>                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680966910"><span class="hs-identifier hs-var">new_rules</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule] -&gt; [CoreRule] -&gt; [CoreRule]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680966942"><span class="hs-identifier hs-var">existing_rules</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1383"></span><span>         </span><span class="hs-comment">-- NB: we look both in the new_rules (generated by this invocation</span><span>
</span><span id="line-1384"></span><span>         </span><span class="hs-comment">--     of specCalls), and in existing_rules (passed in to specCalls)</span><span>
</span><span id="line-1385"></span><span>
</span><span id="line-1386"></span><span>    </span><span class="hs-comment">----------------------------------------------------------</span><span>
</span><span id="line-1387"></span><span>        </span><span class="hs-comment">-- Specialise to one particular call pattern</span><span>
</span><span id="line-1388"></span><span>    </span><span class="annot"><a href="#local-6989586621680966935"><span class="hs-identifier hs-type">spec_call</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecInfo"><span class="hs-identifier hs-type">SpecInfo</span></a></span><span>                         </span><span class="hs-comment">-- Accumulating parameter</span><span>
</span><span id="line-1389"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfo"><span class="hs-identifier hs-type">CallInfo</span></a></span><span>                         </span><span class="hs-comment">-- Call instance</span><span>
</span><span id="line-1390"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecInfo"><span class="hs-identifier hs-type">SpecInfo</span></a></span><span>
</span><span id="line-1391"></span><span>    </span><span id="local-6989586621680966935"><span class="annot"><span class="annottext">spec_call :: ([CoreRule], [(Id, CoreExpr)], UsageDetails)
-&gt; CallInfo -&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
</span><a href="#local-6989586621680966935"><span class="hs-identifier hs-var hs-var">spec_call</span></a></span></span><span> </span><span id="local-6989586621680966906"><span class="annot"><span class="annottext">spec_acc :: ([CoreRule], [(Id, CoreExpr)], UsageDetails)
</span><a href="#local-6989586621680966906"><span class="hs-identifier hs-var">spec_acc</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621680966905"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680966905"><span class="hs-identifier hs-var">rules_acc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966904"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966904"><span class="hs-identifier hs-var">pairs_acc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966903"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966903"><span class="hs-identifier hs-var">uds_acc</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680966902"><span class="annot"><span class="annottext">_ci :: CallInfo
</span><a href="#local-6989586621680966902"><span class="hs-identifier hs-var">_ci</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CI"><span class="hs-identifier hs-type">CI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ci_key :: CallInfo -&gt; [SpecArg]
</span><a href="GHC.Core.Opt.Specialise.html#ci_key"><span class="hs-identifier hs-var">ci_key</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966899"><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966899"><span class="hs-identifier hs-var">call_args</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1392"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- See Note [Specialising Calls]</span><span>
</span><span id="line-1393"></span><span>        </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680966898"><span class="annot"><span class="annottext">all_call_args :: [SpecArg]
</span><a href="#local-6989586621680966898"><span class="hs-identifier hs-var hs-var">all_call_args</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966917"><span class="hs-identifier hs-var">is_dfun</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966899"><span class="hs-identifier hs-var">call_args</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg] -&gt; [SpecArg] -&gt; [SpecArg]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg -&gt; [SpecArg]
forall a. a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#repeat"><span class="hs-identifier hs-var">repeat</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecArg"><span class="hs-identifier hs-var">UnspecArg</span></a></span><span>
</span><span id="line-1394"></span><span>                               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966899"><span class="hs-identifier hs-var">call_args</span></a></span><span>
</span><span id="line-1395"></span><span>                               </span><span class="hs-comment">-- See Note [Specialising DFuns]</span><span>
</span><span id="line-1396"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span> </span><span id="local-6989586621680966895"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966895"><span class="hs-identifier hs-var">useful</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966894"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966894"><span class="hs-identifier hs-var">rhs_env2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966893"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966893"><span class="hs-identifier hs-var">leftover_bndrs</span></a></span></span><span>
</span><span id="line-1397"></span><span>             </span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966892"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966892"><span class="hs-identifier hs-var">rule_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966891"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966891"><span class="hs-identifier hs-var">rule_lhs_args</span></a></span></span><span>
</span><span id="line-1398"></span><span>             </span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966890"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966890"><span class="hs-identifier hs-var">spec_bndrs1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966889"><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966889"><span class="hs-identifier hs-var">dx_binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966888"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966888"><span class="hs-identifier hs-var">spec_args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; [Id]
-&gt; [SpecArg]
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
</span><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var">specHeader</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966943"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966927"><span class="hs-identifier hs-var">rhs_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966898"><span class="hs-identifier hs-var">all_call_args</span></a></span><span>
</span><span id="line-1399"></span><span>
</span><span id="line-1400"></span><span class="hs-comment">--           ; pprTrace &quot;spec_call&quot; (vcat [ text &quot;call info: &quot; &lt;+&gt; ppr _ci</span><span>
</span><span id="line-1401"></span><span class="hs-comment">--                                        , text &quot;useful:    &quot; &lt;+&gt; ppr useful</span><span>
</span><span id="line-1402"></span><span class="hs-comment">--                                        , text &quot;rule_bndrs:&quot; &lt;+&gt; ppr rule_bndrs</span><span>
</span><span id="line-1403"></span><span class="hs-comment">--                                        , text &quot;lhs_args:  &quot; &lt;+&gt; ppr rule_lhs_args</span><span>
</span><span id="line-1404"></span><span class="hs-comment">--                                        , text &quot;spec_bndrs:&quot; &lt;+&gt; ppr spec_bndrs1</span><span>
</span><span id="line-1405"></span><span class="hs-comment">--                                        , text &quot;spec_args: &quot; &lt;+&gt; ppr spec_args</span><span>
</span><span id="line-1406"></span><span class="hs-comment">--                                        , text &quot;dx_binds:  &quot; &lt;+&gt; ppr dx_binds</span><span>
</span><span id="line-1407"></span><span class="hs-comment">--                                        , text &quot;rhs_env2:  &quot; &lt;+&gt; ppr (se_subst rhs_env2)</span><span>
</span><span id="line-1408"></span><span class="hs-comment">--                                        , ppr dx_binds ]) $</span><span>
</span><span id="line-1409"></span><span class="hs-comment">--             return ()</span><span>
</span><span id="line-1410"></span><span>
</span><span id="line-1411"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680966886"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680966886"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecM DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-1412"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680966885"><span class="annot"><span class="annottext">ropts :: RuleOpts
</span><a href="#local-6989586621680966885"><span class="hs-identifier hs-var hs-var">ropts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; RuleOpts
</span><a href="GHC.Core.Rules.html#initRuleOpts"><span class="hs-identifier hs-var">initRuleOpts</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680966886"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-1413"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966895"><span class="hs-identifier hs-var">useful</span></a></span><span>  </span><span class="hs-comment">-- No useful specialisation</span><span>
</span><span id="line-1414"></span><span>                </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">RuleOpts -&gt; [CoreRule] -&gt; [CoreExpr] -&gt; Bool
</span><a href="#local-6989586621680966912"><span class="hs-identifier hs-var">already_covered</span></a></span><span> </span><span class="annot"><span class="annottext">RuleOpts
</span><a href="#local-6989586621680966885"><span class="hs-identifier hs-var">ropts</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680966905"><span class="hs-identifier hs-var">rules_acc</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966891"><span class="hs-identifier hs-var">rule_lhs_args</span></a></span><span>
</span><span id="line-1415"></span><span>             </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">([CoreRule], [(Id, CoreExpr)], UsageDetails)
-&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">([CoreRule], [(Id, CoreExpr)], UsageDetails)
</span><a href="#local-6989586621680966906"><span class="hs-identifier hs-var">spec_acc</span></a></span><span>
</span><span id="line-1416"></span><span>             </span><span class="hs-keyword">else</span><span>
</span><span id="line-1417"></span><span>        </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- Run the specialiser on the specialised RHS</span><span>
</span><span id="line-1418"></span><span>             </span><span class="hs-comment">-- The &quot;1&quot; suffix is before we maybe add the void arg</span><span>
</span><span id="line-1419"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966882"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966882"><span class="hs-identifier hs-var">spec_rhs1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966881"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966881"><span class="hs-identifier hs-var">rhs_uds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; [Id] -&gt; CoreExpr -&gt; SpecM (CoreExpr, UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#specLam"><span class="hs-identifier hs-var">specLam</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966894"><span class="hs-identifier hs-var">rhs_env2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966890"><span class="hs-identifier hs-var">spec_bndrs1</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966893"><span class="hs-identifier hs-var">leftover_bndrs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966915"><span class="hs-identifier hs-var">rhs_body</span></a></span><span>
</span><span id="line-1420"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680966880"><span class="annot"><span class="annottext">spec_fn_ty1 :: Type
</span><a href="#local-6989586621680966880"><span class="hs-identifier hs-var hs-var">spec_fn_ty1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966882"><span class="hs-identifier hs-var">spec_rhs1</span></a></span><span>
</span><span id="line-1421"></span><span>
</span><span id="line-1422"></span><span>                 </span><span class="hs-comment">-- Maybe add a void arg to the specialised function,</span><span>
</span><span id="line-1423"></span><span>                 </span><span class="hs-comment">-- to avoid unlifted bindings</span><span>
</span><span id="line-1424"></span><span>                 </span><span class="hs-comment">-- See Note [Specialisations Must Be Lifted]</span><span>
</span><span id="line-1425"></span><span>                 </span><span class="hs-comment">-- C.f. GHC.Core.Opt.WorkWrap.Utils.mkWorkerArgs</span><span>
</span><span id="line-1426"></span><span>                 </span><span id="local-6989586621680966878"><span class="annot"><span class="annottext">add_void_arg :: Bool
</span><a href="#local-6989586621680966878"><span class="hs-identifier hs-var hs-var">add_void_arg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Bool
Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isUnliftedType"><span class="hs-identifier hs-var">isUnliftedType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966880"><span class="hs-identifier hs-var">spec_fn_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isJoinId"><span class="hs-identifier hs-var">isJoinId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1427"></span><span>                 </span><span class="hs-special">(</span><span id="local-6989586621680966875"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966875"><span class="hs-identifier hs-var">spec_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966874"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966874"><span class="hs-identifier hs-var">spec_rhs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966873"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966873"><span class="hs-identifier hs-var">spec_fn_ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1428"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966878"><span class="hs-identifier hs-var">add_void_arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="GHC.Types.Id.Make.html#voidPrimId"><span class="hs-identifier hs-var">voidPrimId</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966890"><span class="hs-identifier hs-var">spec_bndrs1</span></a></span><span>
</span><span id="line-1429"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreExpr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span>        </span><span class="annot"><span class="annottext">Id
</span><a href="GHC.Types.Id.Make.html#voidArgId"><span class="hs-identifier hs-var">voidArgId</span></a></span><span>  </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966882"><span class="hs-identifier hs-var">spec_rhs1</span></a></span><span>
</span><span id="line-1430"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTyMany"><span class="hs-identifier hs-var">mkVisFunTyMany</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#voidPrimTy"><span class="hs-identifier hs-var">voidPrimTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966880"><span class="hs-identifier hs-var">spec_fn_ty1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1431"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966890"><span class="hs-identifier hs-var">spec_bndrs1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966882"><span class="hs-identifier hs-var">spec_rhs1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966880"><span class="hs-identifier hs-var">spec_fn_ty1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1432"></span><span>
</span><span id="line-1433"></span><span>                 </span><span id="local-6989586621680966867"><span class="annot"><span class="annottext">join_arity_decr :: Int
</span><a href="#local-6989586621680966867"><span class="hs-identifier hs-var hs-var">join_arity_decr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966891"><span class="hs-identifier hs-var">rule_lhs_args</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966875"><span class="hs-identifier hs-var">spec_bndrs</span></a></span><span>
</span><span id="line-1434"></span><span>                 </span><span id="local-6989586621680966864"><span class="annot"><span class="annottext">spec_join_arity :: Maybe Int
</span><a href="#local-6989586621680966864"><span class="hs-identifier hs-var hs-var">spec_join_arity</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680966863"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680966863"><span class="hs-identifier hs-var">orig_join_arity</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Int
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-1435"></span><span>                                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680966863"><span class="hs-identifier hs-var">orig_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680966867"><span class="hs-identifier hs-var">join_arity_decr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1436"></span><span>                                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1437"></span><span>                                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1438"></span><span>
</span><span id="line-1439"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680966861"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966861"><span class="hs-identifier hs-var">spec_fn</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type -&gt; Maybe Int -&gt; SpecM Id
</span><a href="GHC.Core.Opt.Specialise.html#newSpecIdSM"><span class="hs-identifier hs-var">newSpecIdSM</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966873"><span class="hs-identifier hs-var">spec_fn_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680966864"><span class="hs-identifier hs-var">spec_join_arity</span></a></span><span>
</span><span id="line-1440"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680966859"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680966859"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecM Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-1441"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span>
</span><span id="line-1442"></span><span>                </span><span class="hs-comment">-- The rule to put in the function's specialisation is:</span><span>
</span><span id="line-1443"></span><span>                </span><span class="hs-comment">--      forall x @b d1' d2'.</span><span>
</span><span id="line-1444"></span><span>                </span><span class="hs-comment">--          f x @T1 @b @T2 d1' d2' = f1 x @b</span><span>
</span><span id="line-1445"></span><span>                </span><span class="hs-comment">-- See Note [Specialising Calls]</span><span>
</span><span id="line-1446"></span><span>                </span><span id="local-6989586621680966855"><span class="annot"><span class="annottext">herald :: SDoc
</span><a href="#local-6989586621680966855"><span class="hs-identifier hs-var hs-var">herald</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Module
</span><a href="#local-6989586621680966944"><span class="hs-identifier hs-var">mb_mod</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1447"></span><span>                           </span><span class="annot"><span class="annottext">Maybe Module
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>        </span><span class="hs-comment">-- Specialising local fn</span><span>
</span><span id="line-1448"></span><span>                               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;SPEC&quot;</span></span><span>
</span><span id="line-1449"></span><span>                           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680966854"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680966854"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span>  </span><span class="hs-comment">-- Specialising imported fn</span><span>
</span><span id="line-1450"></span><span>                               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;SPEC/&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Module -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680966854"><span class="hs-identifier hs-var">this_mod</span></a></span><span>
</span><span id="line-1451"></span><span>
</span><span id="line-1452"></span><span>                </span><span id="local-6989586621680966850"><span class="annot"><span class="annottext">rule_name :: FastString
</span><a href="#local-6989586621680966850"><span class="hs-identifier hs-var hs-var">rule_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier hs-var">mkFastString</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; FastString) -&gt; String -&gt; FastString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; SDoc -&gt; String
</span><a href="GHC.Utils.Outputable.html#showSDoc"><span class="hs-identifier hs-var">showSDoc</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680966886"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; String) -&gt; SDoc -&gt; String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1453"></span><span>                            </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621680966855"><span class="hs-identifier hs-var">herald</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FastString -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ftext"><span class="hs-identifier hs-var">ftext</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; FastString
</span><a href="GHC.Types.Name.Occurrence.html#occNameFS"><span class="hs-identifier hs-var hs-var">occNameFS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1454"></span><span>                                   </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(SpecArg -&gt; Maybe SDoc) -&gt; [SpecArg] -&gt; [SDoc]
forall a b. (a -&gt; Maybe b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/Data.Maybe.html#mapMaybe"><span class="hs-identifier hs-var">mapMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg -&gt; Maybe SDoc
</span><a href="GHC.Core.Opt.Specialise.html#ppr_call_key_ty"><span class="hs-identifier hs-var">ppr_call_key_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966899"><span class="hs-identifier hs-var">call_args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1455"></span><span>                            </span><span class="hs-comment">-- This name ends up in interface files, so use occNameString.</span><span>
</span><span id="line-1456"></span><span>                            </span><span class="hs-comment">-- Otherwise uniques end up there, making builds</span><span>
</span><span id="line-1457"></span><span>                            </span><span class="hs-comment">-- less deterministic (See #4012 comment:61 ff)</span><span>
</span><span id="line-1458"></span><span>
</span><span id="line-1459"></span><span>                </span><span id="local-6989586621680966842"><span class="annot"><span class="annottext">rule_wout_eta :: CoreRule
</span><a href="#local-6989586621680966842"><span class="hs-identifier hs-var hs-var">rule_wout_eta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Module
-&gt; Bool
-&gt; Bool
-&gt; FastString
-&gt; Activation
-&gt; Name
-&gt; [Id]
-&gt; [CoreExpr]
-&gt; CoreExpr
-&gt; CoreRule
</span><a href="GHC.Core.Rules.html#mkRule"><span class="hs-identifier hs-var">mkRule</span></a></span><span>
</span><span id="line-1460"></span><span>                                  </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680966859"><span class="hs-identifier hs-var">this_mod</span></a></span><span>
</span><span id="line-1461"></span><span>                                  </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-comment">{- Auto generated -}</span><span>
</span><span id="line-1462"></span><span>                                  </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966919"><span class="hs-identifier hs-var">is_local</span></a></span><span>
</span><span id="line-1463"></span><span>                                  </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680966850"><span class="hs-identifier hs-var">rule_name</span></a></span><span>
</span><span id="line-1464"></span><span>                                  </span><span class="annot"><span class="annottext">Activation
</span><a href="#local-6989586621680966921"><span class="hs-identifier hs-var">inl_act</span></a></span><span>       </span><span class="hs-comment">-- Note [Auto-specialisation and RULES]</span><span>
</span><span id="line-1465"></span><span>                                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1466"></span><span>                                  </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966892"><span class="hs-identifier hs-var">rule_bndrs</span></a></span><span>
</span><span id="line-1467"></span><span>                                  </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966891"><span class="hs-identifier hs-var">rule_lhs_args</span></a></span><span>
</span><span id="line-1468"></span><span>                                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; [Id] -&gt; CoreExpr
forall b. Expr b -&gt; [Id] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-identifier hs-var">mkVarApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966861"><span class="hs-identifier hs-var">spec_fn</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966875"><span class="hs-identifier hs-var">spec_bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1469"></span><span>
</span><span id="line-1470"></span><span>                </span><span id="local-6989586621680966839"><span class="annot"><span class="annottext">spec_rule :: CoreRule
</span><a href="#local-6989586621680966839"><span class="hs-identifier hs-var hs-var">spec_rule</span></a></span></span><span>
</span><span id="line-1471"></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Int
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1472"></span><span>                      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680966838"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680966838"><span class="hs-identifier hs-var">join_arity</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; CoreRule -&gt; CoreRule
</span><a href="GHC.Core.Opt.Arity.html#etaExpandToJoinPointRule"><span class="hs-identifier hs-var">etaExpandToJoinPointRule</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680966838"><span class="hs-identifier hs-var">join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680966842"><span class="hs-identifier hs-var">rule_wout_eta</span></a></span><span>
</span><span id="line-1473"></span><span>                      </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680966842"><span class="hs-identifier hs-var">rule_wout_eta</span></a></span><span>
</span><span id="line-1474"></span><span>
</span><span id="line-1475"></span><span>                </span><span class="hs-comment">-- Add the { d1' = dx1; d2' = dx2 } usage stuff</span><span>
</span><span id="line-1476"></span><span>                </span><span class="hs-comment">-- See Note [Specialising Calls]</span><span>
</span><span id="line-1477"></span><span>                </span><span id="local-6989586621680966836"><span class="annot"><span class="annottext">spec_uds :: UsageDetails
</span><a href="#local-6989586621680966836"><span class="hs-identifier hs-var hs-var">spec_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(DictBind -&gt; UsageDetails -&gt; UsageDetails)
-&gt; UsageDetails -&gt; [DictBind] -&gt; UsageDetails
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#consDictBind"><span class="hs-identifier hs-var">consDictBind</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966881"><span class="hs-identifier hs-var">rhs_uds</span></a></span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966889"><span class="hs-identifier hs-var">dx_binds</span></a></span><span>
</span><span id="line-1478"></span><span>
</span><span id="line-1479"></span><span>                </span><span class="hs-comment">--------------------------------------</span><span>
</span><span id="line-1480"></span><span>                </span><span class="hs-comment">-- Add a suitable unfolding if the spec_inl_prag says so</span><span>
</span><span id="line-1481"></span><span>                </span><span class="hs-comment">-- See Note [Inline specialisations]</span><span>
</span><span id="line-1482"></span><span>                </span><span class="hs-special">(</span><span id="local-6989586621680966834"><span class="annot"><span class="annottext">InlinePragma
</span><a href="#local-6989586621680966834"><span class="hs-identifier hs-var">spec_inl_prag</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966833"><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680966833"><span class="hs-identifier hs-var">spec_unf</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1483"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966919"><span class="hs-identifier hs-var">is_local</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isStrongLoopBreaker"><span class="hs-identifier hs-var">isStrongLoopBreaker</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; OccInfo
</span><a href="GHC.Types.Id.html#idOccInfo"><span class="hs-identifier hs-var">idOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1484"></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InlinePragma
</span><a href="GHC.Types.Basic.html#neverInlinePragma"><span class="hs-identifier hs-var">neverInlinePragma</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="GHC.Core.html#noUnfolding"><span class="hs-identifier hs-var">noUnfolding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1485"></span><span>                        </span><span class="hs-comment">-- See Note [Specialising imported functions] in &quot;GHC.Core.Opt.OccurAnal&quot;</span><span>
</span><span id="line-1486"></span><span>
</span><span id="line-1487"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#InlinePragma"><span class="hs-identifier hs-type">InlinePragma</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">inl_inline :: InlinePragma -&gt; InlineSpec
</span><a href="GHC.Types.Basic.html#inl_inline"><span class="hs-identifier hs-var">inl_inline</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InlineSpec
</span><a href="GHC.Types.Basic.html#Inlinable"><span class="hs-identifier hs-var">Inlinable</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InlinePragma
</span><a href="#local-6989586621680966922"><span class="hs-identifier hs-var">inl_prag</span></a></span><span>
</span><span id="line-1488"></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InlinePragma
</span><a href="#local-6989586621680966922"><span class="hs-identifier hs-var">inl_prag</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">inl_inline :: InlineSpec
</span><a href="GHC.Types.Basic.html#inl_inline"><span class="hs-identifier hs-var">inl_inline</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InlineSpec
</span><a href="GHC.Types.Basic.html#NoUserInline"><span class="hs-identifier hs-var">NoUserInline</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="GHC.Core.html#noUnfolding"><span class="hs-identifier hs-var">noUnfolding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1489"></span><span>
</span><span id="line-1490"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1491"></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InlinePragma
</span><a href="#local-6989586621680966922"><span class="hs-identifier hs-var">inl_prag</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; [Id]
-&gt; (CoreExpr -&gt; CoreExpr)
-&gt; [CoreExpr]
-&gt; Unfolding
-&gt; Unfolding
</span><a href="GHC.Core.Unfold.html#specUnfolding"><span class="hs-identifier hs-var">specUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680966886"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966875"><span class="hs-identifier hs-var">spec_bndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-operator hs-var">`mkApps`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966888"><span class="hs-identifier hs-var">spec_args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1492"></span><span>                                             </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966891"><span class="hs-identifier hs-var">rule_lhs_args</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680966923"><span class="hs-identifier hs-var">fn_unf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1493"></span><span>
</span><span id="line-1494"></span><span>                </span><span class="hs-comment">--------------------------------------</span><span>
</span><span id="line-1495"></span><span>                </span><span class="hs-comment">-- Adding arity information just propagates it a bit faster</span><span>
</span><span id="line-1496"></span><span>                </span><span class="hs-comment">--      See Note [Arity decrease] in GHC.Core.Opt.Simplify</span><span>
</span><span id="line-1497"></span><span>                </span><span class="hs-comment">-- Copy InlinePragma information from the parent Id.</span><span>
</span><span id="line-1498"></span><span>                </span><span class="hs-comment">-- So if f has INLINE[1] so does spec_fn</span><span>
</span><span id="line-1499"></span><span>                </span><span id="local-6989586621680966822"><span class="annot"><span class="annottext">arity_decr :: Int
</span><a href="#local-6989586621680966822"><span class="hs-identifier hs-var hs-var">arity_decr</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; Bool) -&gt; [CoreExpr] -&gt; Int
forall a. (a -&gt; Bool) -&gt; [a] -&gt; Int
</span><a href="GHC.Utils.Misc.html#count"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Bool
forall b. Expr b -&gt; Bool
</span><a href="GHC.Core.html#isValArg"><span class="hs-identifier hs-var">isValArg</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966891"><span class="hs-identifier hs-var">rule_lhs_args</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Int
forall a. (a -&gt; Bool) -&gt; [a] -&gt; Int
</span><a href="GHC.Utils.Misc.html#count"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966875"><span class="hs-identifier hs-var">spec_bndrs</span></a></span><span>
</span><span id="line-1500"></span><span>                </span><span id="local-6989586621680966815"><span class="annot"><span class="annottext">spec_f_w_arity :: Id
</span><a href="#local-6989586621680966815"><span class="hs-identifier hs-var hs-var">spec_f_w_arity</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966861"><span class="hs-identifier hs-var">spec_fn</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Int -&gt; Id
</span><a href="GHC.Types.Id.html#setIdArity"><span class="hs-operator hs-var">`setIdArity`</span></a></span><span>      </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-identifier hs-var">max</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680966925"><span class="hs-identifier hs-var">fn_arity</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680966822"><span class="hs-identifier hs-var">arity_decr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1501"></span><span>                                         </span><span class="annot"><span class="annottext">Id -&gt; InlinePragma -&gt; Id
</span><a href="GHC.Types.Id.html#setInlinePragma"><span class="hs-operator hs-var">`setInlinePragma`</span></a></span><span> </span><span class="annot"><span class="annottext">InlinePragma
</span><a href="#local-6989586621680966834"><span class="hs-identifier hs-var">spec_inl_prag</span></a></span><span>
</span><span id="line-1502"></span><span>                                         </span><span class="annot"><span class="annottext">Id -&gt; Unfolding -&gt; Id
</span><a href="GHC.Types.Id.html#setIdUnfolding"><span class="hs-operator hs-var">`setIdUnfolding`</span></a></span><span>  </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680966833"><span class="hs-identifier hs-var">spec_unf</span></a></span><span>
</span><span id="line-1503"></span><span>                                         </span><span class="annot"><span class="annottext">Id -&gt; Maybe Int -&gt; Id
</span><a href="GHC.Types.Id.html#asJoinId_maybe"><span class="hs-operator hs-var">`asJoinId_maybe`</span></a></span><span>  </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680966864"><span class="hs-identifier hs-var">spec_join_arity</span></a></span><span>
</span><span id="line-1504"></span><span>
</span><span id="line-1505"></span><span>                </span><span id="local-6989586621680966799"><span class="annot"><span class="annottext">_rule_trace_doc :: SDoc
</span><a href="#local-6989586621680966799"><span class="hs-identifier hs-var hs-var">_rule_trace_doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966940"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966926"><span class="hs-identifier hs-var">fn_type</span></a></span><span>
</span><span id="line-1506"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966861"><span class="hs-identifier hs-var">spec_fn</span></a></span><span>  </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966873"><span class="hs-identifier hs-var">spec_fn_ty</span></a></span><span>
</span><span id="line-1507"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966927"><span class="hs-identifier hs-var">rhs_bndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[SpecArg] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966899"><span class="hs-identifier hs-var">call_args</span></a></span><span>
</span><span id="line-1508"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680966839"><span class="hs-identifier hs-var">spec_rule</span></a></span><span>
</span><span id="line-1509"></span><span>                                       </span><span class="hs-special">]</span><span>
</span><span id="line-1510"></span><span>
</span><span id="line-1511"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-comment">-- pprTrace &quot;spec_call: rule&quot; _rule_trace_doc</span><span>
</span><span id="line-1512"></span><span>             </span><span class="annot"><span class="annottext">([CoreRule], [(Id, CoreExpr)], UsageDetails)
-&gt; SpecM ([CoreRule], [(Id, CoreExpr)], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680966839"><span class="hs-identifier hs-var">spec_rule</span></a></span><span>                  </span><span class="annot"><span class="annottext">CoreRule -&gt; [CoreRule] -&gt; [CoreRule]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680966905"><span class="hs-identifier hs-var">rules_acc</span></a></span><span>
</span><span id="line-1513"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966815"><span class="hs-identifier hs-var">spec_f_w_arity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966874"><span class="hs-identifier hs-var">spec_rhs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; [(Id, CoreExpr)] -&gt; [(Id, CoreExpr)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966904"><span class="hs-identifier hs-var">pairs_acc</span></a></span><span>
</span><span id="line-1514"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966836"><span class="hs-identifier hs-var">spec_uds</span></a></span><span>           </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#plusUDs"><span class="hs-operator hs-var">`plusUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966903"><span class="hs-identifier hs-var">uds_acc</span></a></span><span>
</span><span id="line-1515"></span><span>                    </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1516"></span><span>
</span><span id="line-1517"></span><span class="hs-comment">{- Note [Specialising DFuns]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DFuns have a special sort of unfolding (DFunUnfolding), and these are
hard to specialise a DFunUnfolding to give another DFunUnfolding
unless the DFun is fully applied (#18120).  So, in the case of DFunIds
we simply extend the CallKey with trailing UnspecArgs, so we'll
generate a rule that completely saturates the DFun.

There is an ASSERT that checks this, in the DFunUnfolding case of
GHC.Core.Unfold.specUnfolding.

Note [Specialisation Must Preserve Sharing]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider a function:

    f :: forall a. Eq a =&gt; a -&gt; blah
    f =
      if expensive
         then f1
         else f2

As written, all calls to 'f' will share 'expensive'. But if we specialise 'f'
at 'Int', eg:

    $sfInt = SUBST[a-&gt;Int,dict-&gt;dEqInt] (if expensive then f1 else f2)

    RULE &quot;SPEC f&quot;
      forall (d :: Eq Int).
        f Int _ = $sfIntf

We've now lost sharing between 'f' and '$sfInt' for 'expensive'. Yikes!

To avoid this, we only generate specialisations for functions whose arity is
enough to bind all of the arguments we need to specialise.  This ensures our
specialised functions don't do any work before receiving all of their dicts,
and thus avoids the 'f' case above.

Note [Specialisations Must Be Lifted]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider a function 'f':

    f = forall a. Eq a =&gt; Array# a

used like

    case x of
      True -&gt; ...f @Int dEqInt...
      False -&gt; 0

Naively, we might generate an (expensive) specialisation

    $sfInt :: Array# Int

even in the case that @x = False@! Instead, we add a dummy 'Void#' argument to
the specialisation '$sfInt' ($sfInt :: Void# -&gt; Array# Int) in order to
preserve laziness.

Note [Specialising Calls]
~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have a function with a complicated type:

    f :: forall a b c. Int -&gt; Eq a =&gt; Show b =&gt; c -&gt; Blah
    f @a @b @c i dEqA dShowA x = blah

and suppose it is called at:

    f 7 @T1 @T2 @T3 dEqT1 ($dfShow dShowT2) t3

This call is described as a 'CallInfo' whose 'ci_key' is:

    [ SpecType T1, SpecType T2, UnspecType, UnspecArg, SpecDict dEqT1
    , SpecDict ($dfShow dShowT2), UnspecArg ]

Why are 'a' and 'b' identified as 'SpecType', while 'c' is 'UnspecType'?
Because we must specialise the function on type variables that appear
free in its *dictionary* arguments; but not on type variables that do not
appear in any dictionaries, i.e. are fully polymorphic.

Because this call has dictionaries applied, we'd like to specialise
the call on any type argument that appears free in those dictionaries.
In this case, those are [a :-&gt; T1, b :-&gt; T2].

We also need to substitute the dictionary binders with their
specialised dictionaries. The simplest substitution would be
[dEqA :-&gt; dEqT1, dShowA :-&gt; $dfShow dShowT2], but this duplicates
work, since `$dfShow dShowT2` is a function application. Therefore, we
also want to *float the dictionary out* (via bindAuxiliaryDict),
creating a new dict binding

    dShow1 = $dfShow dShowT2

and the substitution [dEqA :-&gt; dEqT1, dShowA :-&gt; dShow1].

With the substitutions in hand, we can generate a specialised function:

    $sf :: forall c. Int -&gt; c -&gt; Blah
    $sf = SUBST[a :-&gt; T1, b :-&gt; T2, dEqA :-&gt; dEqT1, dShowA :-&gt; dShow1] (\@c i x -&gt; blah)

Note that the substitution is applied to the whole thing.  This is
convenient, but just slightly fragile.  Notably:
  * There had better be no name clashes in a/b/c

We must construct a rewrite rule:

    RULE &quot;SPEC f @T1 @T2 _&quot;
      forall (@c :: Type) (i :: Int) (d1 :: Eq T1) (d2 :: Show T2).
        f @T1 @T2 @c i d1 d2 = $sf @c i

In the rule, d1 and d2 are just wildcards, not used in the RHS.  Note
additionally that 'x' isn't captured by this rule --- we bind only
enough etas in order to capture all of the *specialised* arguments.

Note [Drop dead args from specialisations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When specialising a function, it&#8217;s possible some of the arguments may
actually be dead. For example, consider:

    f :: forall a. () -&gt; Show a =&gt; a -&gt; String
    f x y = show y ++ &quot;!&quot;

We might generate the following CallInfo for `f @Int`:

    [SpecType Int, UnspecArg, SpecDict $dShowInt, UnspecArg]

Normally we&#8217;d include both the x and y arguments in the
specialisation, since we&#8217;re not specialising on either of them. But
that&#8217;s silly, since x is actually unused! So we might as well drop it
in the specialisation:

    $sf :: Int -&gt; String
    $sf y = show y ++ &quot;!&quot;

    {-# RULE &quot;SPEC f @Int&quot; forall x. f @Int x $dShow = $sf #-}

This doesn&#8217;t save us much, since the arg would be removed later by
worker/wrapper, anyway, but it&#8217;s easy to do. Note, however, that we
only drop dead arguments if:

  1. We don&#8217;t specialise on them.
  2. They come before an argument we do specialise on.

Doing the latter would require eta-expanding the RULE, which could
make it match less often, so it&#8217;s not worth it. Doing the former could
be more useful --- it would stop us from generating pointless
specialisations --- but it&#8217;s more involved to implement and unclear if
it actually provides much benefit in practice.

Note [Zap occ info in rule binders]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we generate a specialisation RULE, we need to drop occurrence
info on the binders. If we don&#8217;t, things go wrong when we specialise a
function like

    f :: forall a. () -&gt; Show a =&gt; a -&gt; String
    f x y = show y ++ &quot;!&quot;

since we&#8217;ll generate a RULE like

    RULE &quot;SPEC f @Int&quot; forall x [Occ=Dead].
      f @Int x $dShow = $sf

and Core Lint complains, even though x only appears on the LHS (due to
Note [Drop dead args from specialisations]).

Why is that a Lint error? Because the arguments on the LHS of a rule
are syntactically expressions, not patterns, so Lint treats the
appearance of x as a use rather than a binding. Fortunately, the
solution is simple: we just make sure to zap the occ info before
using ids as wildcard binders in a rule.

Note [Account for casts in binding]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
   f :: Eq a =&gt; a -&gt; IO ()
   {-# INLINABLE f
       StableUnf = (/\a \(d:Eq a) (x:a). blah) |&gt; g
     #-}
   f = ...

In f's stable unfolding we have done some modest simplification which
has pushed the cast to the outside.  (I wonder if this is the Right
Thing, but it's what happens now; see GHC.Core.Opt.Simplify.Utils Note [Casts and
lambdas].)  Now that stable unfolding must be specialised, so we want
to push the cast back inside. It would be terrible if the cast
defeated specialisation!  Hence the use of collectBindersPushingCo.

Note [Evidence foralls]
~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose (#12212) that we are specialising
   f :: forall a b. (Num a, F a ~ F b) =&gt; blah
with a=b=Int. Then the RULE will be something like
   RULE forall (d:Num Int) (g :: F Int ~ F Int).
        f Int Int d g = f_spec
But both varToCoreExpr (when constructing the LHS args), and the
simplifier (when simplifying the LHS args), will transform to
   RULE forall (d:Num Int) (g :: F Int ~ F Int).
        f Int Int d &lt;F Int&gt; = f_spec
by replacing g with Refl.  So now 'g' is unbound, which results in a later
crash. So we use Refl right off the bat, and do not forall-quantify 'g':
 * varToCoreExpr generates a Refl
 * exprsFreeIdsList returns the Ids bound by the args,
   which won't include g

You might wonder if this will match as often, but the simplifier replaces
complicated Refl coercions with Refl pretty aggressively.

Note [Orphans and auto-generated rules]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we specialise an INLINABLE function, or when we have
-fspecialise-aggressively, we auto-generate RULES that are orphans.
We don't want to warn about these, or we'd generate a lot of warnings.
Thus, we only warn about user-specified orphan rules.

Indeed, we don't even treat the module as an orphan module if it has
auto-generated *rule* orphans.  Orphan modules are read every time we
compile, so they are pretty obtrusive and slow down every compilation,
even non-optimised ones.  (Reason: for type class instances it's a
type correctness issue.)  But specialisation rules are strictly for
*optimisation* only so it's fine not to read the interface.

What this means is that a SPEC rules from auto-specialisation in
module M will be used in other modules only if M.hi has been read for
some other reason, which is actually pretty likely.

Note [From non-recursive to recursive]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Even in the non-recursive case, if any dict-binds depend on 'fn' we might
have built a recursive knot

      f a d x = &lt;blah&gt;
      MkUD { ud_binds = NonRec d7  (MkD ..f..)
           , ud_calls = ...(f T d7)... }

The we generate

     Rec { fs x = &lt;blah&gt;[T/a, d7/d]
           f a d x = &lt;blah&gt;
               RULE f T _ = fs
           d7 = ...f... }

Here the recursion is only through the RULE.

However we definitely should /not/ make the Rec in this wildly common
case:
      d = ...
      MkUD { ud_binds = NonRec d7 (...d...)
           , ud_calls = ...(f T d7)... }

Here we want simply to add d to the floats, giving
      MkUD { ud_binds = NonRec d (...)
                        NonRec d7 (...d...)
           , ud_calls = ...(f T d7)... }

In general, we need only make this Rec if
  - there are some specialisations (spec_binds non-empty)
  - there are some dict_binds that depend on f (dump_dbs non-empty)

Note [Avoiding loops]
~~~~~~~~~~~~~~~~~~~~~
When specialising /dictionary functions/ we must be very careful to
avoid building loops. Here is an example that bit us badly, on
several distinct occasions.

Here is one: #3591
     class Eq a =&gt; C a
     instance Eq [a] =&gt; C [a]

This translates to
     dfun :: Eq [a] -&gt; C [a]
     dfun a d = MkD a d (meth d)

     d4 :: Eq [T] = &lt;blah&gt;
     d2 ::  C [T] = dfun T d4
     d1 :: Eq [T] = $p1 d2
     d3 ::  C [T] = dfun T d1

None of these definitions is recursive. What happened was that we
generated a specialisation:
     RULE forall d. dfun T d = dT  :: C [T]
     dT = (MkD a d (meth d)) [T/a, d1/d]
        = MkD T d1 (meth d1)

But now we use the RULE on the RHS of d2, to get
    d2 = dT = MkD d1 (meth d1)
    d1 = $p1 d2

and now d1 is bottom!  The problem is that when specialising 'dfun' we
should first dump &quot;below&quot; the binding all floated dictionary bindings
that mention 'dfun' itself.  So d2 and d3 (and hence d1) must be
placed below 'dfun', and thus unavailable to it when specialising
'dfun'.  That in turn means that the call (dfun T d1) must be
discarded.  On the other hand, the call (dfun T d4) is fine, assuming
d4 doesn't mention dfun.

Solution:
  Discard all calls that mention dictionaries that depend
  (directly or indirectly) on the dfun we are specialising.
  This is done by 'filterCalls'

--------------
Here's yet another example

  class C a where { foo,bar :: [a] -&gt; [a] }

  instance C Int where
     foo x = r_bar x
     bar xs = reverse xs

  r_bar :: C a =&gt; [a] -&gt; [a]
  r_bar xs = bar (xs ++ xs)

That translates to:

    r_bar a (c::C a) (xs::[a]) = bar a d (xs ++ xs)

    Rec { $fCInt :: C Int = MkC foo_help reverse
          foo_help (xs::[Int]) = r_bar Int $fCInt xs }

The call (r_bar $fCInt) mentions $fCInt,
                        which mentions foo_help,
                        which mentions r_bar
But we DO want to specialise r_bar at Int:

    Rec { $fCInt :: C Int = MkC foo_help reverse
          foo_help (xs::[Int]) = r_bar Int $fCInt xs

          r_bar a (c::C a) (xs::[a]) = bar a d (xs ++ xs)
            RULE r_bar Int _ = r_bar_Int

          r_bar_Int xs = bar Int $fCInt (xs ++ xs)
           }

Note that, because of its RULE, r_bar joins the recursive
group.  (In this case it'll unravel a short moment later.)


Note [Specialising a recursive group]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
    let rec { f x = ...g x'...
            ; g y = ...f y'.... }
    in f 'a'
Here we specialise 'f' at Char; but that is very likely to lead to
a specialisation of 'g' at Char.  We must do the latter, else the
whole point of specialisation is lost.

But we do not want to keep iterating to a fixpoint, because in the
presence of polymorphic recursion we might generate an infinite number
of specialisations.

So we use the following heuristic:
  * Arrange the rec block in dependency order, so far as possible
    (the occurrence analyser already does this)

  * Specialise it much like a sequence of lets

  * Then go through the block a second time, feeding call-info from
    the RHSs back in the bottom, as it were

In effect, the ordering maxmimises the effectiveness of each sweep,
and we do just two sweeps.   This should catch almost every case of
monomorphic recursion -- the exception could be a very knotted-up
recursion with multiple cycles tied up together.

This plan is implemented in the Rec case of specBindItself.

Note [Specialisations already covered]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We obviously don't want to generate two specialisations for the same
argument pattern.  There are two wrinkles

1. We do the already-covered test in specDefn, not when we generate
the CallInfo in mkCallUDs.  We used to test in the latter place, but
we now iterate the specialiser somewhat, and the Id at the call site
might therefore not have all the RULES that we can see in specDefn

2. What about two specialisations where the second is an *instance*
of the first?  If the more specific one shows up first, we'll generate
specialisations for both.  If the *less* specific one shows up first,
we *don't* currently generate a specialisation for the more specific
one.  (See the call to lookupRule in already_covered.)  Reasons:
  (a) lookupRule doesn't say which matches are exact (bad reason)
  (b) if the earlier specialisation is user-provided, it's
      far from clear that we should auto-specialise further

Note [Auto-specialisation and RULES]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider:
   g :: Num a =&gt; a -&gt; a
   g = ...

   f :: (Int -&gt; Int) -&gt; Int
   f w = ...
   {-# RULE f g = 0 #-}

Suppose that auto-specialisation makes a specialised version of
g::Int-&gt;Int That version won't appear in the LHS of the RULE for f.
So if the specialisation rule fires too early, the rule for f may
never fire.

It might be possible to add new rules, to &quot;complete&quot; the rewrite system.
Thus when adding
        RULE forall d. g Int d = g_spec
also add
        RULE f g_spec = 0

But that's a bit complicated.  For now we ask the programmer's help,
by *copying the INLINE activation pragma* to the auto-specialised
rule.  So if g says {-# NOINLINE[2] g #-}, then the auto-spec rule
will also not be active until phase 2.  And that's what programmers
should jolly well do anyway, even aside from specialisation, to ensure
that g doesn't inline too early.

This in turn means that the RULE would never fire for a NOINLINE
thing so not much point in generating a specialisation at all.

Note [Specialisation shape]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
We only specialise a function if it has visible top-level lambdas
corresponding to its overloading.  E.g. if
        f :: forall a. Eq a =&gt; ....
then its body must look like
        f = /\a. \d. ...

Reason: when specialising the body for a call (f ty dexp), we want to
substitute dexp for d, and pick up specialised calls in the body of f.

This doesn't always work.  One example I came across was this:
        newtype Gen a = MkGen{ unGen :: Int -&gt; a }

        choose :: Eq a =&gt; a -&gt; Gen a
        choose n = MkGen (\r -&gt; n)

        oneof = choose (1::Int)

It's a silly example, but we get
        choose = /\a. g `cast` co
where choose doesn't have any dict arguments.  Thus far I have not
tried to fix this (wait till there's a real example).

Mind you, then 'choose' will be inlined (since RHS is trivial) so
it doesn't matter.  This comes up with single-method classes

   class C a where { op :: a -&gt; a }
   instance C a =&gt; C [a] where ....
==&gt;
   $fCList :: C a =&gt; C [a]
   $fCList = $copList |&gt; (...coercion&gt;...)
   ....(uses of $fCList at particular types)...

So we suppress the WARN if the rhs is trivial.

Note [Inline specialisations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here is what we do with the InlinePragma of the original function
  * Activation/RuleMatchInfo: both transferred to the
                              specialised function
  * InlineSpec:
       (a) An INLINE pragma is transferred
       (b) An INLINABLE pragma is *not* transferred

Why (a): transfer INLINE pragmas? The point of INLINE was precisely to
specialise the function at its call site, and arguably that's not so
important for the specialised copies.  BUT *pragma-directed*
specialisation now takes place in the typechecker/desugarer, with
manually specified INLINEs.  The specialisation here is automatic.
It'd be very odd if a function marked INLINE was specialised (because
of some local use), and then forever after (including importing
modules) the specialised version wasn't INLINEd.  After all, the
programmer said INLINE!

You might wonder why we specialise INLINE functions at all.  After
all they should be inlined, right?  Two reasons:

 * Even INLINE functions are sometimes not inlined, when they aren't
   applied to interesting arguments.  But perhaps the type arguments
   alone are enough to specialise (even though the args are too boring
   to trigger inlining), and it's certainly better to call the
   specialised version.

 * The RHS of an INLINE function might call another overloaded function,
   and we'd like to generate a specialised version of that function too.
   This actually happens a lot. Consider
      replicateM_ :: (Monad m) =&gt; Int -&gt; m a -&gt; m ()
      {-# INLINABLE replicateM_ #-}
      replicateM_ d x ma = ...
   The strictness analyser may transform to
      replicateM_ :: (Monad m) =&gt; Int -&gt; m a -&gt; m ()
      {-# INLINE replicateM_ #-}
      replicateM_ d x ma = case x of I# x' -&gt; $wreplicateM_ d x' ma

      $wreplicateM_ :: (Monad m) =&gt; Int# -&gt; m a -&gt; m ()
      {-# INLINABLE $wreplicateM_ #-}
      $wreplicateM_ = ...
   Now an importing module has a specialised call to replicateM_, say
   (replicateM_ dMonadIO).  We certainly want to specialise $wreplicateM_!
   This particular example had a huge effect on the call to replicateM_
   in nofib/shootout/n-body.

Why (b): discard INLINABLE pragmas? See #4874 for persuasive examples.
Suppose we have
    {-# INLINABLE f #-}
    f :: Ord a =&gt; [a] -&gt; Int
    f xs = letrec f' = ...f'... in f'
Then, when f is specialised and optimised we might get
    wgo :: [Int] -&gt; Int#
    wgo = ...wgo...
    f_spec :: [Int] -&gt; Int
    f_spec xs = case wgo xs of { r -&gt; I# r }
and we clearly want to inline f_spec at call sites.  But if we still
have the big, un-optimised of f (albeit specialised) captured in an
INLINABLE pragma for f_spec, we won't get that optimisation.

So we simply drop INLINABLE pragmas when specialising. It's not really
a complete solution; ignoring specialisation for now, INLINABLE functions
don't get properly strictness analysed, for example. But it works well
for examples involving specialisation, which is the dominant use of
INLINABLE.  See #4874.
-}</span><span>
</span><span id="line-2036"></span><span>
</span><span id="line-2037"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
                   SpecArg, and specHeader
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-2042"></span><span>
</span><span id="line-2043"></span><span class="hs-comment">-- | An argument that we might want to specialise.</span><span>
</span><span id="line-2044"></span><span class="hs-comment">-- See Note [Specialising Calls] for the nitty gritty details.</span><span>
</span><span id="line-2045"></span><span class="hs-keyword">data</span><span> </span><span id="SpecArg"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecArg"><span class="hs-identifier hs-var">SpecArg</span></a></span></span><span>
</span><span id="line-2046"></span><span>  </span><span class="hs-glyph">=</span><span>
</span><span id="line-2047"></span><span>    </span><span class="hs-comment">-- | Type arguments that should be specialised, due to appearing</span><span>
</span><span id="line-2048"></span><span>    </span><span class="hs-comment">-- free in the type of a 'SpecDict'.</span><span>
</span><span id="line-2049"></span><span>    </span><span id="SpecType"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecType"><span class="hs-identifier hs-var">SpecType</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-2050"></span><span>
</span><span id="line-2051"></span><span>    </span><span class="hs-comment">-- | Type arguments that should remain polymorphic.</span><span>
</span><span id="line-2052"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="UnspecType"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UnspecType"><span class="hs-identifier hs-var">UnspecType</span></a></span></span><span>
</span><span id="line-2053"></span><span>
</span><span id="line-2054"></span><span>    </span><span class="hs-comment">-- | Dictionaries that should be specialised. mkCallUDs ensures</span><span>
</span><span id="line-2055"></span><span>    </span><span class="hs-comment">-- that only &quot;interesting&quot; dictionary arguments get a SpecDict;</span><span>
</span><span id="line-2056"></span><span>    </span><span class="hs-comment">-- see Note [Interesting dictionary arguments]</span><span>
</span><span id="line-2057"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="SpecDict"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecDict"><span class="hs-identifier hs-var">SpecDict</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictExpr"><span class="hs-identifier hs-type">DictExpr</span></a></span><span>
</span><span id="line-2058"></span><span>
</span><span id="line-2059"></span><span>    </span><span class="hs-comment">-- | Value arguments that should not be specialised.</span><span>
</span><span id="line-2060"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="UnspecArg"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UnspecArg"><span class="hs-identifier hs-var">UnspecArg</span></a></span></span><span>
</span><span id="line-2061"></span><span>
</span><span id="line-2062"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680966791"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecArg"><span class="hs-identifier hs-type">SpecArg</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2063"></span><span>  </span><span id="local-6989586621680966788"><span class="annot"><span class="annottext">ppr :: SpecArg -&gt; SDoc
</span><a href="#local-6989586621680966788"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecType"><span class="hs-identifier hs-type">SpecType</span></a></span><span> </span><span id="local-6989586621680966787"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966787"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;SpecType&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966787"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-2064"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecType"><span class="hs-identifier hs-var">UnspecType</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;UnspecType&quot;</span></span><span>
</span><span id="line-2065"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecDict"><span class="hs-identifier hs-type">SpecDict</span></a></span><span> </span><span id="local-6989586621680966786"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966786"><span class="hs-identifier hs-var">d</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;SpecDict&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966786"><span class="hs-identifier hs-var">d</span></a></span><span>
</span><span id="line-2066"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecArg"><span class="hs-identifier hs-var">UnspecArg</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;UnspecArg&quot;</span></span><span>
</span><span id="line-2067"></span><span>
</span><span id="line-2068"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specArgFreeVars"><span class="hs-identifier hs-type">specArgFreeVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecArg"><span class="hs-identifier hs-type">SpecArg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-2069"></span><span id="specArgFreeVars"><span class="annot"><span class="annottext">specArgFreeVars :: SpecArg -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#specArgFreeVars"><span class="hs-identifier hs-var hs-var">specArgFreeVars</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecType"><span class="hs-identifier hs-type">SpecType</span></a></span><span> </span><span id="local-6989586621680966784"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966784"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966784"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2070"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specArgFreeVars"><span class="hs-identifier hs-var">specArgFreeVars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecDict"><span class="hs-identifier hs-type">SpecDict</span></a></span><span> </span><span id="local-6989586621680966783"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966783"><span class="hs-identifier hs-var">dx</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; VarSet
</span><a href="GHC.Core.FVs.html#exprFreeVars"><span class="hs-identifier hs-var">exprFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966783"><span class="hs-identifier hs-var">dx</span></a></span><span>
</span><span id="line-2071"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specArgFreeVars"><span class="hs-identifier hs-var">specArgFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecType"><span class="hs-identifier hs-var">UnspecType</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span>
</span><span id="line-2072"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specArgFreeVars"><span class="hs-identifier hs-var">specArgFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecArg"><span class="hs-identifier hs-var">UnspecArg</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span>
</span><span id="line-2073"></span><span>
</span><span id="line-2074"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#isSpecDict"><span class="hs-identifier hs-type">isSpecDict</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecArg"><span class="hs-identifier hs-type">SpecArg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2075"></span><span id="isSpecDict"><span class="annot"><span class="annottext">isSpecDict :: SpecArg -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#isSpecDict"><span class="hs-identifier hs-var hs-var">isSpecDict</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecDict"><span class="hs-identifier hs-type">SpecDict</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2076"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#isSpecDict"><span class="hs-identifier hs-var">isSpecDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><span class="hs-identifier">_</span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2077"></span><span>
</span><span id="line-2078"></span><span class="hs-comment">-- | Given binders from an original function 'f', and the 'SpecArg's</span><span>
</span><span id="line-2079"></span><span class="hs-comment">-- corresponding to its usage, compute everything necessary to build</span><span>
</span><span id="line-2080"></span><span class="hs-comment">-- a specialisation.</span><span>
</span><span id="line-2081"></span><span class="hs-comment">--</span><span>
</span><span id="line-2082"></span><span class="hs-comment">-- We will use the running example from Note [Specialising Calls]:</span><span>
</span><span id="line-2083"></span><span class="hs-comment">--</span><span>
</span><span id="line-2084"></span><span class="hs-comment">--     f :: forall a b c. Int -&gt; Eq a =&gt; Show b =&gt; c -&gt; Blah</span><span>
</span><span id="line-2085"></span><span class="hs-comment">--     f @a @b @c i dEqA dShowA x = blah</span><span>
</span><span id="line-2086"></span><span class="hs-comment">--</span><span>
</span><span id="line-2087"></span><span class="hs-comment">-- Suppose we decide to specialise it at the following pattern:</span><span>
</span><span id="line-2088"></span><span class="hs-comment">--</span><span>
</span><span id="line-2089"></span><span class="hs-comment">--     [ SpecType T1, SpecType T2, UnspecType, UnspecArg</span><span>
</span><span id="line-2090"></span><span class="hs-comment">--     , SpecDict dEqT1, SpecDict ($dfShow dShowT2), UnspecArg ]</span><span>
</span><span id="line-2091"></span><span class="hs-comment">--</span><span>
</span><span id="line-2092"></span><span class="hs-comment">-- We'd eventually like to build the RULE</span><span>
</span><span id="line-2093"></span><span class="hs-comment">--</span><span>
</span><span id="line-2094"></span><span class="hs-comment">--     RULE &quot;SPEC f @T1 @T2 _&quot;</span><span>
</span><span id="line-2095"></span><span class="hs-comment">--       forall (@c :: Type) (i :: Int) (d1 :: Eq T1) (d2 :: Show T2).</span><span>
</span><span id="line-2096"></span><span class="hs-comment">--         f @T1 @T2 @c i d1 d2 = $sf @c i</span><span>
</span><span id="line-2097"></span><span class="hs-comment">--</span><span>
</span><span id="line-2098"></span><span class="hs-comment">-- and the specialisation '$sf'</span><span>
</span><span id="line-2099"></span><span class="hs-comment">--</span><span>
</span><span id="line-2100"></span><span class="hs-comment">--     $sf :: forall c. Int -&gt; c -&gt; Blah</span><span>
</span><span id="line-2101"></span><span class="hs-comment">--     $sf = SUBST[a :-&gt; T1, b :-&gt; T2, dEqA :-&gt; dEqT1, dShowA :-&gt; dShow1] (\@c i x -&gt; blah)</span><span>
</span><span id="line-2102"></span><span class="hs-comment">--</span><span>
</span><span id="line-2103"></span><span class="hs-comment">-- where dShow1 is a floated binding created by bindAuxiliaryDict.</span><span>
</span><span id="line-2104"></span><span class="hs-comment">--</span><span>
</span><span id="line-2105"></span><span class="hs-comment">-- The cases for 'specHeader' below are presented in the same order as this</span><span>
</span><span id="line-2106"></span><span class="hs-comment">-- running example. The result of 'specHeader' for this example is as follows:</span><span>
</span><span id="line-2107"></span><span class="hs-comment">--</span><span>
</span><span id="line-2108"></span><span class="hs-comment">--    ( -- Returned arguments</span><span>
</span><span id="line-2109"></span><span class="hs-comment">--      env + [a :-&gt; T1, b :-&gt; T2, dEqA :-&gt; dEqT1, dShowA :-&gt; dShow1]</span><span>
</span><span id="line-2110"></span><span class="hs-comment">--    , [x]</span><span>
</span><span id="line-2111"></span><span class="hs-comment">--</span><span>
</span><span id="line-2112"></span><span class="hs-comment">--      -- RULE helpers</span><span>
</span><span id="line-2113"></span><span class="hs-comment">--    , [c, i, d1, d2]</span><span>
</span><span id="line-2114"></span><span class="hs-comment">--    , [T1, T2, c, i, d1, d2]</span><span>
</span><span id="line-2115"></span><span class="hs-comment">--</span><span>
</span><span id="line-2116"></span><span class="hs-comment">--      -- Specialised function helpers</span><span>
</span><span id="line-2117"></span><span class="hs-comment">--    , [c, i, x]</span><span>
</span><span id="line-2118"></span><span class="hs-comment">--    , [dShow1 = $dfShow dShowT2]</span><span>
</span><span id="line-2119"></span><span class="hs-comment">--    , [T1, T2, c, i, dEqT1, dShow1]</span><span>
</span><span id="line-2120"></span><span class="hs-comment">--    )</span><span>
</span><span id="line-2121"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-type">specHeader</span></a></span><span>
</span><span id="line-2122"></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>
</span><span id="line-2123"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- The binders from the original function 'f'</span><span>
</span><span id="line-2124"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecArg"><span class="hs-identifier hs-type">SpecArg</span></a></span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- From the CallInfo</span><span>
</span><span id="line-2125"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>     </span><span class="hs-comment">-- True &lt;=&gt; some useful specialisation happened</span><span>
</span><span id="line-2126"></span><span>                         </span><span class="hs-comment">-- Not the same as any (isSpecDict args) because</span><span>
</span><span id="line-2127"></span><span>                         </span><span class="hs-comment">-- the args might be longer than bndrs</span><span>
</span><span id="line-2128"></span><span>
</span><span id="line-2129"></span><span>                </span><span class="hs-comment">-- Returned arguments</span><span>
</span><span id="line-2130"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>      </span><span class="hs-comment">-- Substitution to apply to the body of 'f'</span><span>
</span><span id="line-2131"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- Leftover binders from the original function 'f'</span><span>
</span><span id="line-2132"></span><span>                             </span><span class="hs-comment">--   that don&#8217;t have a corresponding SpecArg</span><span>
</span><span id="line-2133"></span><span>
</span><span id="line-2134"></span><span>                </span><span class="hs-comment">-- RULE helpers</span><span>
</span><span id="line-2135"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- Binders for the RULE</span><span>
</span><span id="line-2136"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- Args for the LHS of the rule</span><span>
</span><span id="line-2137"></span><span>
</span><span id="line-2138"></span><span>                </span><span class="hs-comment">-- Specialised function helpers</span><span>
</span><span id="line-2139"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- Binders for $sf</span><span>
</span><span id="line-2140"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- Auxiliary dictionary bindings</span><span>
</span><span id="line-2141"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- Specialised arguments for unfolding</span><span>
</span><span id="line-2142"></span><span>                             </span><span class="hs-comment">-- Same length as &quot;args for LHS of rule&quot;</span><span>
</span><span id="line-2143"></span><span>              </span><span class="hs-special">)</span><span>
</span><span id="line-2144"></span><span>
</span><span id="line-2145"></span><span class="hs-comment">-- We want to specialise on type 'T1', and so we must construct a substitution</span><span>
</span><span id="line-2146"></span><span class="hs-comment">-- 'a-&gt;T1', as well as a LHS argument for the resulting RULE and unfolding</span><span>
</span><span id="line-2147"></span><span class="hs-comment">-- details.</span><span>
</span><span id="line-2148"></span><span id="specHeader"><span class="annot"><span class="annottext">specHeader :: SpecEnv
-&gt; [Id]
-&gt; [SpecArg]
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
</span><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var hs-var">specHeader</span></a></span></span><span> </span><span id="local-6989586621680966779"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966779"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966778"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966778"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680966777"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966777"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecType"><span class="hs-identifier hs-type">SpecType</span></a></span><span> </span><span id="local-6989586621680966776"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966776"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680966775"><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966775"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2149"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680966774"><span class="annot"><span class="annottext">env' :: SpecEnv
</span><a href="#local-6989586621680966774"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; [(Id, Type)] -&gt; SpecEnv
</span><a href="GHC.Core.Opt.Specialise.html#extendTvSubstList"><span class="hs-identifier hs-var">extendTvSubstList</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966779"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966778"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966776"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-2150"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966772"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966772"><span class="hs-identifier hs-var">useful</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966771"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966771"><span class="hs-identifier hs-var">env''</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966770"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966770"><span class="hs-identifier hs-var">leftover_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966769"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966769"><span class="hs-identifier hs-var">rule_bs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966768"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966768"><span class="hs-identifier hs-var">rule_es</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966767"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966767"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966766"><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966766"><span class="hs-identifier hs-var">dx</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966765"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966765"><span class="hs-identifier hs-var">spec_args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2151"></span><span>            </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; [Id]
-&gt; [SpecArg]
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
</span><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var">specHeader</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966774"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966777"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966775"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-2152"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
 [CoreExpr])
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966772"><span class="hs-identifier hs-var">useful</span></a></span><span>
</span><span id="line-2153"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966771"><span class="hs-identifier hs-var">env''</span></a></span><span>
</span><span id="line-2154"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966770"><span class="hs-identifier hs-var">leftover_bndrs</span></a></span><span>
</span><span id="line-2155"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966769"><span class="hs-identifier hs-var">rule_bs</span></a></span><span>
</span><span id="line-2156"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type -&gt; CoreExpr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966776"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966768"><span class="hs-identifier hs-var">rule_es</span></a></span><span>
</span><span id="line-2157"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966767"><span class="hs-identifier hs-var">bs'</span></a></span><span>
</span><span id="line-2158"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966766"><span class="hs-identifier hs-var">dx</span></a></span><span>
</span><span id="line-2159"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type -&gt; CoreExpr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966776"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966765"><span class="hs-identifier hs-var">spec_args</span></a></span><span>
</span><span id="line-2160"></span><span>              </span><span class="hs-special">)</span><span>
</span><span id="line-2161"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-2162"></span><span>
</span><span id="line-2163"></span><span class="hs-comment">-- Next we have a type that we don't want to specialise. We need to perform</span><span>
</span><span id="line-2164"></span><span class="hs-comment">-- a substitution on it (in case the type refers to 'a'). Additionally, we need</span><span>
</span><span id="line-2165"></span><span class="hs-comment">-- to produce a binder, LHS argument and RHS argument for the resulting rule,</span><span>
</span><span id="line-2166"></span><span class="hs-comment">-- /and/ a binder for the specialised body.</span><span>
</span><span id="line-2167"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var">specHeader</span></a></span><span> </span><span id="local-6989586621680966764"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966764"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966763"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966763"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680966762"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966762"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecType"><span class="hs-identifier hs-var">UnspecType</span></a></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680966761"><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966761"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2168"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966760"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966760"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966759"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966759"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; Id -&gt; (SpecEnv, Id)
</span><a href="GHC.Core.Opt.Specialise.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966764"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966763"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2169"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966758"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966758"><span class="hs-identifier hs-var">useful</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966757"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966757"><span class="hs-identifier hs-var">env''</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966756"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966756"><span class="hs-identifier hs-var">leftover_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966755"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966755"><span class="hs-identifier hs-var">rule_bs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966754"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966754"><span class="hs-identifier hs-var">rule_es</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966753"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966753"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966752"><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966752"><span class="hs-identifier hs-var">dx</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966751"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966751"><span class="hs-identifier hs-var">spec_args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2170"></span><span>            </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; [Id]
-&gt; [SpecArg]
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
</span><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var">specHeader</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966760"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966762"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966761"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-2171"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
 [CoreExpr])
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966758"><span class="hs-identifier hs-var">useful</span></a></span><span>
</span><span id="line-2172"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966757"><span class="hs-identifier hs-var">env''</span></a></span><span>
</span><span id="line-2173"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966756"><span class="hs-identifier hs-var">leftover_bndrs</span></a></span><span>
</span><span id="line-2174"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966759"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966755"><span class="hs-identifier hs-var">rule_bs</span></a></span><span>
</span><span id="line-2175"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966759"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966754"><span class="hs-identifier hs-var">rule_es</span></a></span><span>
</span><span id="line-2176"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966759"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966753"><span class="hs-identifier hs-var">bs'</span></a></span><span>
</span><span id="line-2177"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966752"><span class="hs-identifier hs-var">dx</span></a></span><span>
</span><span id="line-2178"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966759"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966751"><span class="hs-identifier hs-var">spec_args</span></a></span><span>
</span><span id="line-2179"></span><span>              </span><span class="hs-special">)</span><span>
</span><span id="line-2180"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-2181"></span><span>
</span><span id="line-2182"></span><span class="hs-comment">-- Next we want to specialise the 'Eq a' dict away. We need to construct</span><span>
</span><span id="line-2183"></span><span class="hs-comment">-- a wildcard binder to match the dictionary (See Note [Specialising Calls] for</span><span>
</span><span id="line-2184"></span><span class="hs-comment">-- the nitty-gritty), as a LHS rule and unfolding details.</span><span>
</span><span id="line-2185"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var">specHeader</span></a></span><span> </span><span id="local-6989586621680966749"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966749"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966748"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966748"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680966747"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966747"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecDict"><span class="hs-identifier hs-type">SpecDict</span></a></span><span> </span><span id="local-6989586621680966746"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966746"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680966745"><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966745"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2186"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680966744"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966744"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; Id -&gt; SpecM Id
</span><a href="GHC.Core.Opt.Specialise.html#newDictBndr"><span class="hs-identifier hs-var">newDictBndr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966749"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966748"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-comment">-- See Note [Zap occ info in rule binders]</span><span>
</span><span id="line-2187"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966742"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966742"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966741"><span class="annot"><span class="annottext">Maybe DictBind
</span><a href="#local-6989586621680966741"><span class="hs-identifier hs-var">dx_bind</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966740"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966740"><span class="hs-identifier hs-var">spec_dict</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; Id -&gt; Id -&gt; CoreExpr -&gt; (SpecEnv, Maybe DictBind, CoreExpr)
</span><a href="GHC.Core.Opt.Specialise.html#bindAuxiliaryDict"><span class="hs-identifier hs-var">bindAuxiliaryDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966749"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966748"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966744"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966746"><span class="hs-identifier hs-var">d</span></a></span><span>
</span><span id="line-2188"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966738"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966738"><span class="hs-identifier hs-var">env''</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966737"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966737"><span class="hs-identifier hs-var">leftover_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966736"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966736"><span class="hs-identifier hs-var">rule_bs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966735"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966735"><span class="hs-identifier hs-var">rule_es</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966734"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966734"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966733"><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966733"><span class="hs-identifier hs-var">dx</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966732"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966732"><span class="hs-identifier hs-var">spec_args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2189"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; [Id]
-&gt; [SpecArg]
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
</span><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var">specHeader</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966742"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966747"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966745"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-2190"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
 [CoreExpr])
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>      </span><span class="hs-comment">-- Ha!  A useful specialisation!</span><span>
</span><span id="line-2191"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966738"><span class="hs-identifier hs-var">env''</span></a></span><span>
</span><span id="line-2192"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966737"><span class="hs-identifier hs-var">leftover_bndrs</span></a></span><span>
</span><span id="line-2193"></span><span>              </span><span class="hs-comment">-- See Note [Evidence foralls]</span><span>
</span><span id="line-2194"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [Id]
</span><a href="GHC.Core.FVs.html#exprFreeIdsList"><span class="hs-identifier hs-var">exprFreeIdsList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966744"><span class="hs-identifier hs-var">bndr'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966736"><span class="hs-identifier hs-var">rule_bs</span></a></span><span>
</span><span id="line-2195"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966744"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966735"><span class="hs-identifier hs-var">rule_es</span></a></span><span>
</span><span id="line-2196"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966734"><span class="hs-identifier hs-var">bs'</span></a></span><span>
</span><span id="line-2197"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe DictBind -&gt; [DictBind]
forall a. Maybe a -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#maybeToList"><span class="hs-identifier hs-var">maybeToList</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe DictBind
</span><a href="#local-6989586621680966741"><span class="hs-identifier hs-var">dx_bind</span></a></span><span> </span><span class="annot"><span class="annottext">[DictBind] -&gt; [DictBind] -&gt; [DictBind]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966733"><span class="hs-identifier hs-var">dx</span></a></span><span>
</span><span id="line-2198"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966740"><span class="hs-identifier hs-var">spec_dict</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966732"><span class="hs-identifier hs-var">spec_args</span></a></span><span>
</span><span id="line-2199"></span><span>              </span><span class="hs-special">)</span><span>
</span><span id="line-2200"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-2201"></span><span>
</span><span id="line-2202"></span><span class="hs-comment">-- Finally, we have the unspecialised argument 'i'. We need to produce</span><span>
</span><span id="line-2203"></span><span class="hs-comment">-- a binder, LHS and RHS argument for the RULE, and a binder for the</span><span>
</span><span id="line-2204"></span><span class="hs-comment">-- specialised body.</span><span>
</span><span id="line-2205"></span><span class="hs-comment">--</span><span>
</span><span id="line-2206"></span><span class="hs-comment">-- NB: Calls to 'specHeader' will trim off any trailing 'UnspecArg's, which is</span><span>
</span><span id="line-2207"></span><span class="hs-comment">-- why 'i' doesn't appear in our RULE above. But we have no guarantee that</span><span>
</span><span id="line-2208"></span><span class="hs-comment">-- there aren't 'UnspecArg's which come /before/ all of the dictionaries, so</span><span>
</span><span id="line-2209"></span><span class="hs-comment">-- this case must be here.</span><span>
</span><span id="line-2210"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var">specHeader</span></a></span><span> </span><span id="local-6989586621680966730"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966730"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966729"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966729"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680966728"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966728"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecArg"><span class="hs-identifier hs-var">UnspecArg</span></a></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680966727"><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966727"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2211"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- see Note [Zap occ info in rule binders]</span><span>
</span><span id="line-2212"></span><span>         </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966726"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966726"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966725"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966725"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; Id -&gt; (SpecEnv, Id)
</span><a href="GHC.Core.Opt.Specialise.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966730"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="GHC.Types.Id.html#zapIdOccInfo"><span class="hs-identifier hs-var">zapIdOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966729"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2213"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966723"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966723"><span class="hs-identifier hs-var">useful</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966722"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966722"><span class="hs-identifier hs-var">env''</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966721"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966721"><span class="hs-identifier hs-var">leftover_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966720"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966720"><span class="hs-identifier hs-var">rule_bs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966719"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966719"><span class="hs-identifier hs-var">rule_es</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966718"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966718"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966717"><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966717"><span class="hs-identifier hs-var">dx</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966716"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966716"><span class="hs-identifier hs-var">spec_args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2214"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecEnv
-&gt; [Id]
-&gt; [SpecArg]
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
</span><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var">specHeader</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966726"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966728"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966727"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-2215"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
 [CoreExpr])
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966723"><span class="hs-identifier hs-var">useful</span></a></span><span>
</span><span id="line-2216"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966722"><span class="hs-identifier hs-var">env''</span></a></span><span>
</span><span id="line-2217"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966721"><span class="hs-identifier hs-var">leftover_bndrs</span></a></span><span>
</span><span id="line-2218"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966725"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966720"><span class="hs-identifier hs-var">rule_bs</span></a></span><span>
</span><span id="line-2219"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966725"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966719"><span class="hs-identifier hs-var">rule_es</span></a></span><span>
</span><span id="line-2220"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isDeadBinder"><span class="hs-identifier hs-var">isDeadBinder</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966729"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2221"></span><span>                  </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966718"><span class="hs-identifier hs-var">bs'</span></a></span><span> </span><span class="hs-comment">-- see Note [Drop dead args from specialisations]</span><span>
</span><span id="line-2222"></span><span>                  </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966725"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966718"><span class="hs-identifier hs-var">bs'</span></a></span><span>
</span><span id="line-2223"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966717"><span class="hs-identifier hs-var">dx</span></a></span><span>
</span><span id="line-2224"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966725"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966716"><span class="hs-identifier hs-var">spec_args</span></a></span><span>
</span><span id="line-2225"></span><span>              </span><span class="hs-special">)</span><span>
</span><span id="line-2226"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-2227"></span><span>
</span><span id="line-2228"></span><span class="hs-comment">-- If we run out of binders, stop immediately</span><span>
</span><span id="line-2229"></span><span class="hs-comment">-- See Note [Specialisation Must Preserve Sharing]</span><span>
</span><span id="line-2230"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var">specHeader</span></a></span><span> </span><span id="local-6989586621680966715"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966715"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
 [CoreExpr])
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966715"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2231"></span><span>
</span><span id="line-2232"></span><span class="hs-comment">-- Return all remaining binders from the original function. These have the</span><span>
</span><span id="line-2233"></span><span class="hs-comment">-- invariant that they should all correspond to unspecialised arguments, so</span><span>
</span><span id="line-2234"></span><span class="hs-comment">-- it's safe to stop processing at this point.</span><span>
</span><span id="line-2235"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#specHeader"><span class="hs-identifier hs-var">specHeader</span></a></span><span> </span><span id="local-6989586621680966714"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966714"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966713"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966713"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-2236"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
 [CoreExpr])
-&gt; SpecM
     (Bool, SpecEnv, [Id], [Id], [CoreExpr], [Id], [DictBind],
      [CoreExpr])
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966712"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966711"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2237"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2238"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680966712"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966712"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966711"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966711"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; [Id] -&gt; (SpecEnv, [Id])
</span><a href="GHC.Core.Opt.Specialise.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966714"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966713"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2239"></span><span>
</span><span id="line-2240"></span><span>
</span><span id="line-2241"></span><span class="hs-comment">-- | Binds a dictionary argument to a fresh name, to preserve sharing</span><span>
</span><span id="line-2242"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#bindAuxiliaryDict"><span class="hs-identifier hs-type">bindAuxiliaryDict</span></a></span><span>
</span><span id="line-2243"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>
</span><span id="line-2244"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InId"><span class="hs-identifier hs-type">InId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-comment">-- Original dict binder, and the witnessing expression</span><span>
</span><span id="line-2245"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>        </span><span class="hs-comment">-- Substitute for orig_dict_id</span><span>
</span><span id="line-2246"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span> </span><span class="hs-comment">-- Auxiliary dict binding, if any</span><span>
</span><span id="line-2247"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span class="hs-special">)</span><span>        </span><span class="hs-comment">-- Witnessing expression (always trivial)</span><span>
</span><span id="line-2248"></span><span id="bindAuxiliaryDict"><span class="annot"><span class="annottext">bindAuxiliaryDict :: SpecEnv
-&gt; Id -&gt; Id -&gt; CoreExpr -&gt; (SpecEnv, Maybe DictBind, CoreExpr)
</span><a href="GHC.Core.Opt.Specialise.html#bindAuxiliaryDict"><span class="hs-identifier hs-var hs-var">bindAuxiliaryDict</span></a></span></span><span> </span><span id="local-6989586621680966709"><span class="annot"><span class="annottext">env :: SpecEnv
</span><a href="#local-6989586621680966709"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SE"><span class="hs-identifier hs-type">SE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966708"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966708"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">se_interesting :: SpecEnv -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var">se_interesting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966707"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966707"><span class="hs-identifier hs-var">interesting</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2249"></span><span>                  </span><span id="local-6989586621680966706"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966706"><span class="hs-identifier hs-var">orig_dict_id</span></a></span></span><span> </span><span id="local-6989586621680966705"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966705"><span class="hs-identifier hs-var">fresh_dict_id</span></a></span></span><span> </span><span id="local-6989586621680966704"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966704"><span class="hs-identifier hs-var">dict_expr</span></a></span></span><span>
</span><span id="line-2250"></span><span>
</span><span id="line-2251"></span><span>  </span><span class="hs-comment">-- If the dictionary argument is trivial,</span><span>
</span><span id="line-2252"></span><span>  </span><span class="hs-comment">-- don&#8217;t bother creating a new dict binding; just substitute</span><span>
</span><span id="line-2253"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680966703"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966703"><span class="hs-identifier hs-var">dict_id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Maybe Id
</span><a href="GHC.Core.Utils.html#getIdFromTrivialExpr_maybe"><span class="hs-identifier hs-var">getIdFromTrivialExpr_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966704"><span class="hs-identifier hs-var">dict_expr</span></a></span><span>
</span><span id="line-2254"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680966702"><span class="annot"><span class="annottext">env' :: SpecEnv
</span><a href="#local-6989586621680966702"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966709"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; CoreExpr -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendSubst"><span class="hs-identifier hs-var">Core.extendSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966708"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966706"><span class="hs-identifier hs-var">orig_dict_id</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966704"><span class="hs-identifier hs-var">dict_expr</span></a></span><span>
</span><span id="line-2255"></span><span>                                </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendInScope"><span class="hs-operator hs-var">`Core.extendInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966703"><span class="hs-identifier hs-var">dict_id</span></a></span><span>
</span><span id="line-2256"></span><span>                          </span><span class="hs-comment">-- See Note [Keep the old dictionaries interesting]</span><span>
</span><span id="line-2257"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">se_interesting :: VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var">se_interesting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966707"><span class="hs-identifier hs-var">interesting</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966703"><span class="hs-identifier hs-var">dict_id</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2258"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966702"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe DictBind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966704"><span class="hs-identifier hs-var">dict_expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2259"></span><span>
</span><span id="line-2260"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-comment">-- Non-trivial dictionary arg; make an auxiliary binding</span><span>
</span><span id="line-2261"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680966698"><span class="annot"><span class="annottext">dict_bind :: DictBind
</span><a href="#local-6989586621680966698"><span class="hs-identifier hs-var hs-var">dict_bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#mkDB"><span class="hs-identifier hs-var">mkDB</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966705"><span class="hs-identifier hs-var">fresh_dict_id</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966704"><span class="hs-identifier hs-var">dict_expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2262"></span><span>        </span><span id="local-6989586621680966697"><span class="annot"><span class="annottext">env' :: SpecEnv
</span><a href="#local-6989586621680966697"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966709"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; CoreExpr -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendSubst"><span class="hs-identifier hs-var">Core.extendSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966708"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966706"><span class="hs-identifier hs-var">orig_dict_id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966705"><span class="hs-identifier hs-var">fresh_dict_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2263"></span><span>                                </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendInScope"><span class="hs-operator hs-var">`Core.extendInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966705"><span class="hs-identifier hs-var">fresh_dict_id</span></a></span><span>
</span><span id="line-2264"></span><span>                      </span><span class="hs-comment">-- See Note [Make the new dictionaries interesting]</span><span>
</span><span id="line-2265"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">se_interesting :: VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var">se_interesting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966707"><span class="hs-identifier hs-var">interesting</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966705"><span class="hs-identifier hs-var">fresh_dict_id</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2266"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966697"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DictBind -&gt; Maybe DictBind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966698"><span class="hs-identifier hs-var">dict_bind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966705"><span class="hs-identifier hs-var">fresh_dict_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2267"></span><span>
</span><span id="line-2268"></span><span class="hs-comment">{-
Note [Make the new dictionaries interesting]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Important!  We're going to substitute dx_id1 for d
and we want it to look &quot;interesting&quot;, else we won't gather *any*
consequential calls. E.g.
    f d = ...g d....
If we specialise f for a call (f (dfun dNumInt)), we'll get
a consequent call (g d') with an auxiliary definition
    d' = df dNumInt
We want that consequent call to look interesting

Note [Keep the old dictionaries interesting]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In bindAuxiliaryDict, we don&#8217;t bother creating a new dict binding if
the dict expression is trivial. For example, if we have

    f = \ @m1 (d1 :: Monad m1) -&gt; ...

and we specialize it at the pattern

    [SpecType IO, SpecArg $dMonadIO]

it would be silly to create a new binding for $dMonadIO; it&#8217;s already
a binding! So we just extend the substitution directly:

    m1 :-&gt; IO
    d1 :-&gt; $dMonadIO

But this creates a new subtlety: the dict expression might be a dict
binding we floated out while specializing another function. For
example, we might have

    d2 = $p1Monad $dMonadIO -- floated out by bindAuxiliaryDict
    $sg = h @IO d2
    h = \ @m2 (d2 :: Applicative m2) -&gt; ...

and end up specializing h at the following pattern:

    [SpecType IO, SpecArg d2]

When we created the d2 binding in the first place, we locally marked
it as interesting while specializing g as described above by
Note [Make the new dictionaries interesting]. But when we go to
specialize h, it isn&#8217;t in the SpecEnv anymore, so we&#8217;ve lost the
knowledge that we should specialize on it.

To fix this, we have to explicitly add d2 *back* to the interesting
set. That way, it will still be considered interesting while
specializing the body of h. See !2913.
-}</span><span>
</span><span id="line-2319"></span><span>
</span><span id="line-2320"></span><span>
</span><span id="line-2321"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
            UsageDetails and suchlike
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-2326"></span><span>
</span><span id="line-2327"></span><span class="hs-keyword">data</span><span> </span><span id="UsageDetails"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-var">UsageDetails</span></a></span></span><span>
</span><span id="line-2328"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="MkUD"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-var">MkUD</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-2329"></span><span>      </span><span id="ud_binds"><span class="annot"><span class="annottext">UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var hs-var">ud_binds</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-2330"></span><span>               </span><span class="hs-comment">-- See Note [Floated dictionary bindings]</span><span>
</span><span id="line-2331"></span><span>               </span><span class="hs-comment">-- The order is important;</span><span>
</span><span id="line-2332"></span><span>               </span><span class="hs-comment">-- in ds1 `union` ds2, bindings in ds2 can depend on those in ds1</span><span>
</span><span id="line-2333"></span><span>               </span><span class="hs-comment">-- (Remember, Bags preserve order in GHC.)</span><span>
</span><span id="line-2334"></span><span>
</span><span id="line-2335"></span><span>      </span><span id="ud_calls"><span class="annot"><span class="annottext">UsageDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var hs-var">ud_calls</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-type">CallDetails</span></a></span><span>
</span><span id="line-2336"></span><span>
</span><span id="line-2337"></span><span>      </span><span class="hs-comment">-- INVARIANT: suppose bs = bindersOf ud_binds</span><span>
</span><span id="line-2338"></span><span>      </span><span class="hs-comment">-- Then 'calls' may *mention* 'bs',</span><span>
</span><span id="line-2339"></span><span>      </span><span class="hs-comment">-- but there should be no calls *for* bs</span><span>
</span><span id="line-2340"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-2341"></span><span>
</span><span id="line-2342"></span><span class="hs-comment">-- | A 'DictBind' is a binding along with a cached set containing its free</span><span>
</span><span id="line-2343"></span><span class="hs-comment">-- variables (both type variables and dictionaries)</span><span>
</span><span id="line-2344"></span><span class="hs-keyword">data</span><span> </span><span id="DictBind"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-var">DictBind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="DB"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DB"><span class="hs-identifier hs-var">DB</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="db_bind"><span class="annot"><span class="annottext">DictBind -&gt; CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var hs-var">db_bind</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">,</span><span> </span><span id="db_fvs"><span class="annot"><span class="annottext">DictBind -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#db_fvs"><span class="hs-identifier hs-var hs-var">db_fvs</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2345"></span><span>
</span><span id="line-2346"></span><span class="hs-comment">{- Note [Floated dictionary bindings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We float out dictionary bindings for the reasons described under
&quot;Dictionary floating&quot; above.  But not /just/ dictionary bindings.
Consider

   f :: Eq a =&gt; blah
   f a d = rhs

   $c== :: T -&gt; T -&gt; Bool
   $c== x y = ...

   $df :: Eq T
   $df = Eq $c== ...

   gurgle = ...(f @T $df)...

We gather the call info for (f @T $df), and we don't want to drop it
when we come across the binding for $df.  So we add $df to the floats
and continue.  But then we have to add $c== to the floats, and so on.
These all float above the binding for 'f', and now we can
successfully specialise 'f'.

So the DictBinds in (ud_binds :: Bag DictBind) may contain
non-dictionary bindings too.
-}</span><span>
</span><span id="line-2372"></span><span>
</span><span id="line-2373"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680966694"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2374"></span><span>  </span><span id="local-6989586621680966690"><span class="annot"><span class="annottext">ppr :: DictBind -&gt; SDoc
</span><a href="#local-6989586621680966690"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DB"><span class="hs-identifier hs-type">DB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">db_bind :: DictBind -&gt; CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var">db_bind</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966689"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966689"><span class="hs-identifier hs-var">bind</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">db_fvs :: DictBind -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#db_fvs"><span class="hs-identifier hs-var">db_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966688"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966688"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2375"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DB&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;bind:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966689"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-2376"></span><span>                                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fvs: &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966688"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2377"></span><span>
</span><span id="line-2378"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680966685"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2379"></span><span>  </span><span id="local-6989586621680966678"><span class="annot"><span class="annottext">ppr :: UsageDetails -&gt; SDoc
</span><a href="#local-6989586621680966678"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966677"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966677"><span class="hs-identifier hs-var">dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: UsageDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966676"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966676"><span class="hs-identifier hs-var">calls</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2380"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;MkUD&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; [SDoc] -&gt; [SDoc]
</span><a href="GHC.Utils.Outputable.html#punctuate"><span class="hs-identifier hs-var">punctuate</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span>
</span><span id="line-2381"></span><span>                </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;binds&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#equals"><span class="hs-identifier hs-var">equals</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966677"><span class="hs-identifier hs-var">dbs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-2382"></span><span>                 </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;calls&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#equals"><span class="hs-identifier hs-var">equals</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966676"><span class="hs-identifier hs-var">calls</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2383"></span><span>
</span><span id="line-2384"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-type">emptyUDs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2385"></span><span id="emptyUDs"><span class="annot"><span class="annottext">emptyUDs :: UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var hs-var">emptyUDs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MkUD :: Bag DictBind -&gt; CallDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallDetails
forall a. DVarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyDVarEnv"><span class="hs-identifier hs-var">emptyDVarEnv</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2386"></span><span>
</span><span id="line-2387"></span><span class="hs-comment">------------------------------------------------------------</span><span>
</span><span id="line-2388"></span><span class="hs-keyword">type</span><span> </span><span id="CallDetails"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-var">CallDetails</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#DIdEnv"><span class="hs-identifier hs-type">DIdEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span><span>
</span><span id="line-2389"></span><span>  </span><span class="hs-comment">-- The order of specialized binds and rules depends on how we linearize</span><span>
</span><span id="line-2390"></span><span>  </span><span class="hs-comment">-- CallDetails, so to get determinism we must use a deterministic set here.</span><span>
</span><span id="line-2391"></span><span>  </span><span class="hs-comment">-- See Note [Deterministic UniqFM] in GHC.Types.Unique.DFM</span><span>
</span><span id="line-2392"></span><span>
</span><span id="line-2393"></span><span class="hs-keyword">data</span><span> </span><span id="CallInfoSet"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-var">CallInfoSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="CIS"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-var">CIS</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfo"><span class="hs-identifier hs-type">CallInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2394"></span><span>  </span><span class="hs-comment">-- The list of types and dictionaries is guaranteed to</span><span>
</span><span id="line-2395"></span><span>  </span><span class="hs-comment">-- match the type of f</span><span>
</span><span id="line-2396"></span><span>  </span><span class="hs-comment">-- The Bag may contain duplicate calls (i.e. f @T and another f @T)</span><span>
</span><span id="line-2397"></span><span>  </span><span class="hs-comment">-- These dups are eliminated by already_covered in specCalls</span><span>
</span><span id="line-2398"></span><span>
</span><span id="line-2399"></span><span class="hs-keyword">data</span><span> </span><span id="CallInfo"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfo"><span class="hs-identifier hs-var">CallInfo</span></a></span></span><span>
</span><span id="line-2400"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="CI"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CI"><span class="hs-identifier hs-var">CI</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="ci_key"><span class="annot"><span class="annottext">CallInfo -&gt; [SpecArg]
</span><a href="GHC.Core.Opt.Specialise.html#ci_key"><span class="hs-identifier hs-var hs-var">ci_key</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecArg"><span class="hs-identifier hs-type">SpecArg</span></a></span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- All arguments</span><span>
</span><span id="line-2401"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="ci_fvs"><span class="annot"><span class="annottext">CallInfo -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#ci_fvs"><span class="hs-identifier hs-var hs-var">ci_fvs</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>      </span><span class="hs-comment">-- Free vars of the ci_key</span><span>
</span><span id="line-2402"></span><span>                                </span><span class="hs-comment">-- call (including tyvars)</span><span>
</span><span id="line-2403"></span><span>                                </span><span class="hs-comment">-- [*not* include the main id itself, of course]</span><span>
</span><span id="line-2404"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-2405"></span><span>
</span><span id="line-2406"></span><span class="hs-keyword">type</span><span> </span><span id="DictExpr"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictExpr"><span class="hs-identifier hs-var">DictExpr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-2407"></span><span>
</span><span id="line-2408"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#ciSetFilter"><span class="hs-identifier hs-type">ciSetFilter</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfo"><span class="hs-identifier hs-type">CallInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span><span>
</span><span id="line-2409"></span><span id="ciSetFilter"><span class="annot"><span class="annottext">ciSetFilter :: (CallInfo -&gt; Bool) -&gt; CallInfoSet -&gt; CallInfoSet
</span><a href="GHC.Core.Opt.Specialise.html#ciSetFilter"><span class="hs-identifier hs-var hs-var">ciSetFilter</span></a></span></span><span> </span><span id="local-6989586621680966669"><span class="annot"><span class="annottext">CallInfo -&gt; Bool
</span><a href="#local-6989586621680966669"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-type">CIS</span></a></span><span> </span><span id="local-6989586621680966668"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966668"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680966667"><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966667"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bag CallInfo -&gt; CallInfoSet
</span><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-var">CIS</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966668"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CallInfo -&gt; Bool) -&gt; Bag CallInfo -&gt; Bag CallInfo
forall a. (a -&gt; Bool) -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#filterBag"><span class="hs-identifier hs-var">filterBag</span></a></span><span> </span><span class="annot"><span class="annottext">CallInfo -&gt; Bool
</span><a href="#local-6989586621680966669"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966667"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2410"></span><span>
</span><span id="line-2411"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680966663"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2412"></span><span>  </span><span id="local-6989586621680966659"><span class="annot"><span class="annottext">ppr :: CallInfoSet -&gt; SDoc
</span><a href="#local-6989586621680966659"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-type">CIS</span></a></span><span> </span><span id="local-6989586621680966658"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966658"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621680966657"><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966657"><span class="hs-identifier hs-var">map</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;CIS&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966658"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2413"></span><span>                        </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag CallInfo -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966657"><span class="hs-identifier hs-var">map</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2414"></span><span>
</span><span id="line-2415"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#pprCallInfo"><span class="hs-identifier hs-type">pprCallInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfo"><span class="hs-identifier hs-type">CallInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2416"></span><span id="pprCallInfo"><span class="annot"><span class="annottext">pprCallInfo :: Id -&gt; CallInfo -&gt; SDoc
</span><a href="GHC.Core.Opt.Specialise.html#pprCallInfo"><span class="hs-identifier hs-var hs-var">pprCallInfo</span></a></span></span><span> </span><span id="local-6989586621680966656"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966656"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CI"><span class="hs-identifier hs-type">CI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ci_key :: CallInfo -&gt; [SpecArg]
</span><a href="GHC.Core.Opt.Specialise.html#ci_key"><span class="hs-identifier hs-var">ci_key</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966655"><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966655"><span class="hs-identifier hs-var">key</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2417"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966656"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966655"><span class="hs-identifier hs-var">key</span></a></span><span>
</span><span id="line-2418"></span><span>
</span><span id="line-2419"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#ppr_call_key_ty"><span class="hs-identifier hs-type">ppr_call_key_ty</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecArg"><span class="hs-identifier hs-type">SpecArg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2420"></span><span id="ppr_call_key_ty"><span class="annot"><span class="annottext">ppr_call_key_ty :: SpecArg -&gt; Maybe SDoc
</span><a href="GHC.Core.Opt.Specialise.html#ppr_call_key_ty"><span class="hs-identifier hs-var hs-var">ppr_call_key_ty</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecType"><span class="hs-identifier hs-type">SpecType</span></a></span><span> </span><span id="local-6989586621680966654"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966654"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Maybe SDoc
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; Maybe SDoc) -&gt; SDoc -&gt; Maybe SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'@'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprParendType"><span class="hs-identifier hs-var">pprParendType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966654"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2421"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#ppr_call_key_ty"><span class="hs-identifier hs-var">ppr_call_key_ty</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecType"><span class="hs-identifier hs-var">UnspecType</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Maybe SDoc
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; Maybe SDoc) -&gt; SDoc -&gt; Maybe SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'_'</span></span><span>
</span><span id="line-2422"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#ppr_call_key_ty"><span class="hs-identifier hs-var">ppr_call_key_ty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecDict"><span class="hs-identifier hs-type">SpecDict</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe SDoc
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-2423"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#ppr_call_key_ty"><span class="hs-identifier hs-var">ppr_call_key_ty</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecArg"><span class="hs-identifier hs-var">UnspecArg</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe SDoc
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-2424"></span><span>
</span><span id="line-2425"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680966649"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfo"><span class="hs-identifier hs-type">CallInfo</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2426"></span><span>  </span><span id="local-6989586621680966647"><span class="annot"><span class="annottext">ppr :: CallInfo -&gt; SDoc
</span><a href="#local-6989586621680966647"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CI"><span class="hs-identifier hs-type">CI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ci_key :: CallInfo -&gt; [SpecArg]
</span><a href="GHC.Core.Opt.Specialise.html#ci_key"><span class="hs-identifier hs-var">ci_key</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966646"><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966646"><span class="hs-identifier hs-var">key</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ci_fvs :: CallInfo -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#ci_fvs"><span class="hs-identifier hs-var">ci_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966645"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966645"><span class="hs-identifier hs-var">_fvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2427"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;CI&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(SpecArg -&gt; SDoc) -&gt; [SpecArg] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966646"><span class="hs-identifier hs-var">key</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2428"></span><span>
</span><span id="line-2429"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#unionCalls"><span class="hs-identifier hs-type">unionCalls</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-type">CallDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-type">CallDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-type">CallDetails</span></a></span><span>
</span><span id="line-2430"></span><span id="unionCalls"><span class="annot"><span class="annottext">unionCalls :: CallDetails -&gt; CallDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#unionCalls"><span class="hs-identifier hs-var hs-var">unionCalls</span></a></span></span><span> </span><span id="local-6989586621680966643"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966643"><span class="hs-identifier hs-var">c1</span></a></span></span><span> </span><span id="local-6989586621680966642"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966642"><span class="hs-identifier hs-var">c2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CallInfoSet -&gt; CallInfoSet -&gt; CallInfoSet)
-&gt; CallDetails -&gt; CallDetails -&gt; CallDetails
forall a. (a -&gt; a -&gt; a) -&gt; DVarEnv a -&gt; DVarEnv a -&gt; DVarEnv a
</span><a href="GHC.Types.Var.Env.html#plusDVarEnv_C"><span class="hs-identifier hs-var">plusDVarEnv_C</span></a></span><span> </span><span class="annot"><span class="annottext">CallInfoSet -&gt; CallInfoSet -&gt; CallInfoSet
</span><a href="GHC.Core.Opt.Specialise.html#unionCallInfoSet"><span class="hs-identifier hs-var">unionCallInfoSet</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966643"><span class="hs-identifier hs-var">c1</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966642"><span class="hs-identifier hs-var">c2</span></a></span><span>
</span><span id="line-2431"></span><span>
</span><span id="line-2432"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#unionCallInfoSet"><span class="hs-identifier hs-type">unionCallInfoSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span><span>
</span><span id="line-2433"></span><span id="unionCallInfoSet"><span class="annot"><span class="annottext">unionCallInfoSet :: CallInfoSet -&gt; CallInfoSet -&gt; CallInfoSet
</span><a href="GHC.Core.Opt.Specialise.html#unionCallInfoSet"><span class="hs-identifier hs-var hs-var">unionCallInfoSet</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-type">CIS</span></a></span><span> </span><span id="local-6989586621680966639"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966639"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680966638"><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966638"><span class="hs-identifier hs-var">calls1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-type">CIS</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680966637"><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966637"><span class="hs-identifier hs-var">calls2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-2434"></span><span>  </span><span class="annot"><span class="annottext">Id -&gt; Bag CallInfo -&gt; CallInfoSet
</span><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-var">CIS</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966639"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966638"><span class="hs-identifier hs-var">calls1</span></a></span><span> </span><span class="annot"><span class="annottext">Bag CallInfo -&gt; Bag CallInfo -&gt; Bag CallInfo
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966637"><span class="hs-identifier hs-var">calls2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2435"></span><span>
</span><span id="line-2436"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#callDetailsFVs"><span class="hs-identifier hs-type">callDetailsFVs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-type">CallDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-2437"></span><span id="callDetailsFVs"><span class="annot"><span class="annottext">callDetailsFVs :: CallDetails -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#callDetailsFVs"><span class="hs-identifier hs-var hs-var">callDetailsFVs</span></a></span></span><span> </span><span id="local-6989586621680966635"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966635"><span class="hs-identifier hs-var">calls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-2438"></span><span>  </span><span class="annot"><span class="annottext">(CallInfoSet -&gt; VarSet -&gt; VarSet)
-&gt; VarSet -&gt; CallDetails -&gt; VarSet
forall elt a key. (elt -&gt; a -&gt; a) -&gt; a -&gt; UniqDFM key elt -&gt; a
</span><a href="GHC.Types.Unique.DFM.html#nonDetStrictFoldUDFM"><span class="hs-identifier hs-var">nonDetStrictFoldUDFM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-identifier hs-var">unionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; VarSet -&gt; VarSet)
-&gt; (CallInfoSet -&gt; VarSet) -&gt; CallInfoSet -&gt; VarSet -&gt; VarSet
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CallInfoSet -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#callInfoFVs"><span class="hs-identifier hs-var">callInfoFVs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966635"><span class="hs-identifier hs-var">calls</span></a></span><span>
</span><span id="line-2439"></span><span>  </span><span class="hs-comment">-- It's OK to use nonDetStrictFoldUDFM here because we forget the ordering</span><span>
</span><span id="line-2440"></span><span>  </span><span class="hs-comment">-- immediately by converting to a nondeterministic set.</span><span>
</span><span id="line-2441"></span><span>
</span><span id="line-2442"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#callInfoFVs"><span class="hs-identifier hs-type">callInfoFVs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-2443"></span><span id="callInfoFVs"><span class="annot"><span class="annottext">callInfoFVs :: CallInfoSet -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#callInfoFVs"><span class="hs-identifier hs-var hs-var">callInfoFVs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-type">CIS</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680966631"><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966631"><span class="hs-identifier hs-var">call_info</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-2444"></span><span>  </span><span class="annot"><span class="annottext">(CallInfo -&gt; VarSet -&gt; VarSet) -&gt; VarSet -&gt; Bag CallInfo -&gt; VarSet
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CI"><span class="hs-identifier hs-type">CI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ci_fvs :: CallInfo -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#ci_fvs"><span class="hs-identifier hs-var">ci_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966630"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966630"><span class="hs-identifier hs-var">fv</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680966629"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966629"><span class="hs-identifier hs-var">vs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-identifier hs-var">unionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966630"><span class="hs-identifier hs-var">fv</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966629"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966631"><span class="hs-identifier hs-var">call_info</span></a></span><span>
</span><span id="line-2445"></span><span>
</span><span id="line-2446"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#getTheta"><span class="hs-identifier hs-type">getTheta</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyCoBinder"><span class="hs-identifier hs-type">TyCoBinder</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2447"></span><span id="getTheta"><span class="annot"><span class="annottext">getTheta :: [TyCoBinder] -&gt; [Type]
</span><a href="GHC.Core.Opt.Specialise.html#getTheta"><span class="hs-identifier hs-var hs-var">getTheta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyCoBinder -&gt; Type) -&gt; [TyCoBinder] -&gt; [Type]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoBinder -&gt; Type
</span><a href="GHC.Core.Type.html#tyBinderType"><span class="hs-identifier hs-var">tyBinderType</span></a></span><span> </span><span class="annot"><span class="annottext">([TyCoBinder] -&gt; [Type])
-&gt; ([TyCoBinder] -&gt; [TyCoBinder]) -&gt; [TyCoBinder] -&gt; [Type]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCoBinder -&gt; Bool) -&gt; [TyCoBinder] -&gt; [TyCoBinder]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoBinder -&gt; Bool
</span><a href="GHC.Core.TyCo.Rep.html#isInvisibleBinder"><span class="hs-identifier hs-var">isInvisibleBinder</span></a></span><span> </span><span class="annot"><span class="annottext">([TyCoBinder] -&gt; [TyCoBinder])
-&gt; ([TyCoBinder] -&gt; [TyCoBinder]) -&gt; [TyCoBinder] -&gt; [TyCoBinder]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCoBinder -&gt; Bool) -&gt; [TyCoBinder] -&gt; [TyCoBinder]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; (TyCoBinder -&gt; Bool) -&gt; TyCoBinder -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoBinder -&gt; Bool
</span><a href="GHC.Core.TyCo.Rep.html#isNamedBinder"><span class="hs-identifier hs-var">isNamedBinder</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2448"></span><span>
</span><span id="line-2449"></span><span>
</span><span id="line-2450"></span><span class="hs-comment">------------------------------------------------------------</span><span>
</span><span id="line-2451"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#singleCall"><span class="hs-identifier hs-type">singleCall</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecArg"><span class="hs-identifier hs-type">SpecArg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2452"></span><span id="singleCall"><span class="annot"><span class="annottext">singleCall :: Id -&gt; [SpecArg] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#singleCall"><span class="hs-identifier hs-var hs-var">singleCall</span></a></span></span><span> </span><span id="local-6989586621680966622"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966622"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680966621"><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966621"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-2453"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MkUD :: Bag DictBind -&gt; CallDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">ud_binds :: Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-2454"></span><span>          </span><span class="annot"><span class="annottext">ud_calls :: CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CallInfoSet -&gt; CallDetails
forall a. Id -&gt; a -&gt; DVarEnv a
</span><a href="GHC.Types.Var.Env.html#unitDVarEnv"><span class="hs-identifier hs-var">unitDVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966622"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">(CallInfoSet -&gt; CallDetails) -&gt; CallInfoSet -&gt; CallDetails
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bag CallInfo -&gt; CallInfoSet
</span><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-var">CIS</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966622"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">(Bag CallInfo -&gt; CallInfoSet) -&gt; Bag CallInfo -&gt; CallInfoSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2455"></span><span>                     </span><span class="annot"><span class="annottext">CallInfo -&gt; Bag CallInfo
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CI :: [SpecArg] -&gt; VarSet -&gt; CallInfo
</span><a href="GHC.Core.Opt.Specialise.html#CI"><span class="hs-identifier hs-type">CI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ci_key :: [SpecArg]
</span><a href="GHC.Core.Opt.Specialise.html#ci_key"><span class="hs-identifier hs-var">ci_key</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966621"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="hs-comment">-- used to be tys</span><span>
</span><span id="line-2456"></span><span>                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ci_fvs :: VarSet
</span><a href="GHC.Core.Opt.Specialise.html#ci_fvs"><span class="hs-identifier hs-var">ci_fvs</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966618"><span class="hs-identifier hs-var">call_fvs</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2457"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2458"></span><span>    </span><span id="local-6989586621680966618"><span class="annot"><span class="annottext">call_fvs :: VarSet
</span><a href="#local-6989586621680966618"><span class="hs-identifier hs-var hs-var">call_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SpecArg -&gt; VarSet -&gt; VarSet) -&gt; VarSet -&gt; [SpecArg] -&gt; VarSet
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-identifier hs-var">unionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; VarSet -&gt; VarSet)
-&gt; (SpecArg -&gt; VarSet) -&gt; SpecArg -&gt; VarSet -&gt; VarSet
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#specArgFreeVars"><span class="hs-identifier hs-var">specArgFreeVars</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966621"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-2459"></span><span>        </span><span class="hs-comment">-- The type args (tys) are guaranteed to be part of the dictionary</span><span>
</span><span id="line-2460"></span><span>        </span><span class="hs-comment">-- types, because they are just the constrained types,</span><span>
</span><span id="line-2461"></span><span>        </span><span class="hs-comment">-- and the dictionary is therefore sure to be bound</span><span>
</span><span id="line-2462"></span><span>        </span><span class="hs-comment">-- inside the binding for any type variables free in the type;</span><span>
</span><span id="line-2463"></span><span>        </span><span class="hs-comment">-- hence it's safe to neglect tyvars free in tys when making</span><span>
</span><span id="line-2464"></span><span>        </span><span class="hs-comment">-- the free-var set for this call</span><span>
</span><span id="line-2465"></span><span>        </span><span class="hs-comment">-- BUT I don't trust this reasoning; play safe and include tys_fvs</span><span>
</span><span id="line-2466"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-2467"></span><span>        </span><span class="hs-comment">-- We don't include the 'id' itself.</span><span>
</span><span id="line-2468"></span><span>
</span><span id="line-2469"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#mkCallUDs"><span class="hs-identifier hs-type">mkCallUDs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#mkCallUDs%27"><span class="hs-identifier hs-type">mkCallUDs'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2470"></span><span id="mkCallUDs"><span class="annot"><span class="annottext">mkCallUDs :: SpecEnv -&gt; Id -&gt; [CoreExpr] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#mkCallUDs"><span class="hs-identifier hs-var hs-var">mkCallUDs</span></a></span></span><span> </span><span id="local-6989586621680966615"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966615"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966614"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966614"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680966613"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966613"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-2471"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;mkCallUDs&quot; (vcat [ ppr f, ppr args, ppr res ])</span><span>
</span><span id="line-2472"></span><span>    </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966612"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-2473"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2474"></span><span>    </span><span id="local-6989586621680966612"><span class="annot"><span class="annottext">res :: UsageDetails
</span><a href="#local-6989586621680966612"><span class="hs-identifier hs-var hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; Id -&gt; [CoreExpr] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#mkCallUDs%27"><span class="hs-identifier hs-var">mkCallUDs'</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966615"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966614"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966613"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-2475"></span><span>
</span><span id="line-2476"></span><span id="mkCallUDs%27"><span class="annot"><span class="annottext">mkCallUDs' :: SpecEnv -&gt; Id -&gt; [CoreExpr] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#mkCallUDs%27"><span class="hs-identifier hs-var hs-var">mkCallUDs'</span></a></span></span><span> </span><span id="local-6989586621680966611"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966611"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966610"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966610"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680966609"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966609"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-2477"></span><span>  </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680966608"><span class="hs-identifier hs-var">want_calls_for</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966610"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Imported from elsewhere</span><span>
</span><span id="line-2478"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">[SpecArg] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966607"><span class="hs-identifier hs-var">ci_key</span></a></span><span>             </span><span class="hs-comment">-- No useful specialisation</span><span>
</span><span id="line-2479"></span><span>   </span><span class="hs-comment">-- See also Note [Specialisations already covered]</span><span>
</span><span id="line-2480"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;mkCallUDs: discarding&quot; _trace_doc</span><span>
</span><span id="line-2481"></span><span>    </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var">emptyUDs</span></a></span><span>
</span><span id="line-2482"></span><span>
</span><span id="line-2483"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2484"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;mkCallUDs: keeping&quot; _trace_doc</span><span>
</span><span id="line-2485"></span><span>    </span><span class="annot"><span class="annottext">Id -&gt; [SpecArg] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#singleCall"><span class="hs-identifier hs-var">singleCall</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966610"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966607"><span class="hs-identifier hs-var">ci_key</span></a></span><span>
</span><span id="line-2486"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2487"></span><span>    </span><span id="local-6989586621680966600"><span class="annot"><span class="annottext">_trace_doc :: SDoc
</span><a href="#local-6989586621680966600"><span class="hs-identifier hs-var hs-var">_trace_doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966610"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966609"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[SpecArg] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[SpecArg]
</span><a href="#local-6989586621680966607"><span class="hs-identifier hs-var">ci_key</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2488"></span><span>    </span><span id="local-6989586621680966599"><span class="annot"><span class="annottext">pis :: [TyCoBinder]
</span><a href="#local-6989586621680966599"><span class="hs-identifier hs-var hs-var">pis</span></a></span></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([TyCoBinder], Type) -&gt; [TyCoBinder]
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(([TyCoBinder], Type) -&gt; [TyCoBinder])
-&gt; ([TyCoBinder], Type) -&gt; [TyCoBinder]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([TyCoBinder], Type)
</span><a href="GHC.Core.Type.html#splitPiTys"><span class="hs-identifier hs-var">splitPiTys</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; ([TyCoBinder], Type)) -&gt; Type -&gt; ([TyCoBinder], Type)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966610"><span class="hs-identifier hs-var">f</span></a></span><span>
</span><span id="line-2489"></span><span>    </span><span id="local-6989586621680966597"><span class="annot"><span class="annottext">constrained_tyvars :: VarSet
</span><a href="#local-6989586621680966597"><span class="hs-identifier hs-var hs-var">constrained_tyvars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">([Type] -&gt; VarSet) -&gt; [Type] -&gt; VarSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoBinder] -&gt; [Type]
</span><a href="GHC.Core.Opt.Specialise.html#getTheta"><span class="hs-identifier hs-var">getTheta</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoBinder]
</span><a href="#local-6989586621680966599"><span class="hs-identifier hs-var">pis</span></a></span><span>
</span><span id="line-2490"></span><span>
</span><span id="line-2491"></span><span>    </span><span class="annot"><a href="#local-6989586621680966607"><span class="hs-identifier hs-type">ci_key</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecArg"><span class="hs-identifier hs-type">SpecArg</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2492"></span><span>    </span><span id="local-6989586621680966607"><span class="annot"><span class="annottext">ci_key :: [SpecArg]
</span><a href="#local-6989586621680966607"><span class="hs-identifier hs-var hs-var">ci_key</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SpecArg -&gt; Bool) -&gt; [SpecArg] -&gt; [SpecArg]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#dropWhileEndLE"><span class="hs-identifier hs-var">dropWhileEndLE</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; (SpecArg -&gt; Bool) -&gt; SpecArg -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">SpecArg -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#isSpecDict"><span class="hs-identifier hs-var">isSpecDict</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([SpecArg] -&gt; [SpecArg]) -&gt; [SpecArg] -&gt; [SpecArg]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2493"></span><span>             </span><span class="annot"><span class="annottext">(CoreExpr -&gt; TyCoBinder -&gt; SpecArg)
-&gt; [CoreExpr] -&gt; [TyCoBinder] -&gt; [SpecArg]
forall a b c. (a -&gt; b -&gt; c) -&gt; [a] -&gt; [b] -&gt; [c]
</span><a href="../../base/src/GHC.List.html#zipWith"><span class="hs-identifier hs-var">zipWith</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; TyCoBinder -&gt; SpecArg
</span><a href="#local-6989586621680966593"><span class="hs-identifier hs-var">mk_spec_arg</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680966609"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoBinder]
</span><a href="#local-6989586621680966599"><span class="hs-identifier hs-var">pis</span></a></span><span>
</span><span id="line-2494"></span><span>             </span><span class="hs-comment">-- Drop trailing args until we get to a SpecDict</span><span>
</span><span id="line-2495"></span><span>             </span><span class="hs-comment">-- In this way the RULE has as few args as possible,</span><span>
</span><span id="line-2496"></span><span>             </span><span class="hs-comment">-- which broadens its applicability, since rules only</span><span>
</span><span id="line-2497"></span><span>             </span><span class="hs-comment">-- fire when saturated</span><span>
</span><span id="line-2498"></span><span>
</span><span id="line-2499"></span><span>    </span><span class="annot"><a href="#local-6989586621680966593"><span class="hs-identifier hs-type">mk_spec_arg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyCoBinder"><span class="hs-identifier hs-type">TyCoBinder</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecArg"><span class="hs-identifier hs-type">SpecArg</span></a></span><span>
</span><span id="line-2500"></span><span>    </span><span id="local-6989586621680966593"><span class="annot"><span class="annottext">mk_spec_arg :: CoreExpr -&gt; TyCoBinder -&gt; SpecArg
</span><a href="#local-6989586621680966593"><span class="hs-identifier hs-var hs-var">mk_spec_arg</span></a></span></span><span> </span><span id="local-6989586621680966592"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966592"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Named"><span class="hs-identifier hs-type">Named</span></a></span><span> </span><span id="local-6989586621680966590"><span class="annot"><span class="annottext">TyCoVarBinder
</span><a href="#local-6989586621680966590"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2501"></span><span>      </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">TyCoVarBinder -&gt; Id
forall tv argf. VarBndr tv argf -&gt; tv
</span><a href="GHC.Types.Var.html#binderVar"><span class="hs-identifier hs-var">binderVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarBinder
</span><a href="#local-6989586621680966590"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966597"><span class="hs-identifier hs-var">constrained_tyvars</span></a></span><span>
</span><span id="line-2502"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966592"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2503"></span><span>          </span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span id="local-6989586621680966587"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966587"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type -&gt; SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#SpecType"><span class="hs-identifier hs-var">SpecType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966587"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2504"></span><span>          </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; SpecArg
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ci_key&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SpecArg) -&gt; SDoc -&gt; SpecArg
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966592"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-2505"></span><span>      </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecType"><span class="hs-identifier hs-var">UnspecType</span></a></span><span>
</span><span id="line-2506"></span><span>
</span><span id="line-2507"></span><span>    </span><span class="hs-comment">-- For &quot;InvisArg&quot;, which are the type-class dictionaries,</span><span>
</span><span id="line-2508"></span><span>    </span><span class="hs-comment">-- we decide on a case by case basis if we want to specialise</span><span>
</span><span id="line-2509"></span><span>    </span><span class="hs-comment">-- on this argument; if so, SpecDict, if not UnspecArg</span><span>
</span><span id="line-2510"></span><span>    </span><span class="annot"><a href="#local-6989586621680966593"><span class="hs-identifier hs-var">mk_spec_arg</span></a></span><span> </span><span id="local-6989586621680966585"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966585"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Anon"><span class="hs-identifier hs-type">Anon</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="GHC.Types.Var.html#InvisArg"><span class="hs-identifier hs-var">InvisArg</span></a></span><span> </span><span id="local-6989586621680966582"><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621680966582"><span class="hs-identifier hs-var">pred</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2511"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isIPLikePred"><span class="hs-identifier hs-var">isIPLikePred</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Scaled Type -&gt; Type
forall a. Scaled a -&gt; a
</span><a href="GHC.Core.TyCo.Rep.html#scaledThing"><span class="hs-identifier hs-var">scaledThing</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621680966582"><span class="hs-identifier hs-var">pred</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2512"></span><span>              </span><span class="hs-comment">-- See Note [Type determines value]</span><span>
</span><span id="line-2513"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966611"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966585"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-2514"></span><span>              </span><span class="hs-comment">-- See Note [Interesting dictionary arguments]</span><span>
</span><span id="line-2515"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#SpecDict"><span class="hs-identifier hs-var">SpecDict</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966585"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-2516"></span><span>
</span><span id="line-2517"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecArg"><span class="hs-identifier hs-var">UnspecArg</span></a></span><span>
</span><span id="line-2518"></span><span>
</span><span id="line-2519"></span><span>    </span><span class="annot"><a href="#local-6989586621680966593"><span class="hs-identifier hs-var">mk_spec_arg</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Anon"><span class="hs-identifier hs-type">Anon</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="GHC.Types.Var.html#VisArg"><span class="hs-identifier hs-var">VisArg</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-2520"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecArg
</span><a href="GHC.Core.Opt.Specialise.html#UnspecArg"><span class="hs-identifier hs-var">UnspecArg</span></a></span><span>
</span><span id="line-2521"></span><span>
</span><span id="line-2522"></span><span>    </span><span id="local-6989586621680966608"><span class="annot"><span class="annottext">want_calls_for :: Id -&gt; Bool
</span><a href="#local-6989586621680966608"><span class="hs-identifier hs-var hs-var">want_calls_for</span></a></span></span><span> </span><span id="local-6989586621680966578"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966578"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isLocalId"><span class="hs-identifier hs-var">isLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966578"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Maybe CoreExpr -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unfolding -&gt; Maybe CoreExpr
</span><a href="GHC.Core.html#maybeUnfoldingTemplate"><span class="hs-identifier hs-var">maybeUnfoldingTemplate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Unfolding
</span><a href="GHC.Types.Id.html#realIdUnfolding"><span class="hs-identifier hs-var">realIdUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966578"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2523"></span><span>         </span><span class="hs-comment">-- For imported things, we gather call instances if</span><span>
</span><span id="line-2524"></span><span>         </span><span class="hs-comment">-- there is an unfolding that we could in principle specialise</span><span>
</span><span id="line-2525"></span><span>         </span><span class="hs-comment">-- We might still decide not to use it (consulting dflags)</span><span>
</span><span id="line-2526"></span><span>         </span><span class="hs-comment">-- in specImports</span><span>
</span><span id="line-2527"></span><span>         </span><span class="hs-comment">-- Use 'realIdUnfolding' to ignore the loop-breaker flag!</span><span>
</span><span id="line-2528"></span><span>
</span><span id="line-2529"></span><span class="hs-comment">{- Note [Type determines value]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Only specialise on non-impicit-parameter predicates, because these
are the ones whose *type* determines their *value*.  In particular,
with implicit params, the type args *don't* say what the value of the
implicit param is!  See #7101.

So we treat implicit params just like ordinary arguments for the
purposes of specialisation.  Note that we still want to specialise
functions with implicit params if they have *other* dicts which are
class params; see #17930.

Note [Interesting dictionary arguments]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this
         \a.\d:Eq a.  let f = ... in ...(f d)...
There really is not much point in specialising f wrt the dictionary d,
because the code for the specialised f is not improved at all, because
d is lambda-bound.  We simply get junk specialisations.

What is &quot;interesting&quot;?  Just that it has *some* structure.  But what about
variables?

 * A variable might be imported, in which case its unfolding
   will tell us whether it has useful structure

 * Local variables are cloned on the way down (to avoid clashes when
   we float dictionaries), and cloning drops the unfolding
   (cloneIdBndr).  Moreover, we make up some new bindings, and it's a
   nuisance to give them unfoldings.  So we keep track of the
   &quot;interesting&quot; dictionaries as a VarSet in SpecEnv.
   We have to take care to put any new interesting dictionary
   bindings in the set.

We accidentally lost accurate tracking of local variables for a long
time, because cloned variables don't have unfoldings. But makes a
massive difference in a few cases, eg #5113. For nofib as a
whole it's only a small win: 2.2% improvement in allocation for ansi,
1.2% for bspt, but mostly 0.0!  Average 0.1% increase in binary size.
-}</span><span>
</span><span id="line-2569"></span><span>
</span><span id="line-2570"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-type">interestingDict</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2571"></span><span class="hs-comment">-- A dictionary argument is interesting if it has *some* structure</span><span>
</span><span id="line-2572"></span><span class="hs-comment">-- NB: &quot;dictionary&quot; arguments include constraints of all sorts,</span><span>
</span><span id="line-2573"></span><span class="hs-comment">--     including equality constraints; hence the Coercion case</span><span>
</span><span id="line-2574"></span><span id="interestingDict"><span class="annot"><span class="annottext">interestingDict :: SpecEnv -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var hs-var">interestingDict</span></a></span></span><span> </span><span id="local-6989586621680966577"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966577"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680966576"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966576"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">Unfolding -&gt; Bool
</span><a href="GHC.Core.html#hasSomeUnfolding"><span class="hs-identifier hs-var">hasSomeUnfolding</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Unfolding
</span><a href="GHC.Types.Id.html#idUnfolding"><span class="hs-identifier hs-var">idUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966576"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2575"></span><span>                            </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isDataConWorkId"><span class="hs-identifier hs-var">isDataConWorkId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966576"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-2576"></span><span>                            </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966576"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var hs-var">se_interesting</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966577"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-2577"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2578"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2579"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span id="local-6989586621680966572"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966572"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680966571"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966571"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966572"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966571"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-2580"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span id="local-6989586621680966570"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966570"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680966569"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966569"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966570"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966569"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-2581"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span id="local-6989586621680966568"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966568"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680966567"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966567"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966568"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966567"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-2582"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span id="local-6989586621680966566"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966566"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680966565"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966565"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966566"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966565"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-2583"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span>                       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2584"></span><span>
</span><span id="line-2585"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#plusUDs"><span class="hs-identifier hs-type">plusUDs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2586"></span><span id="plusUDs"><span class="annot"><span class="annottext">plusUDs :: UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#plusUDs"><span class="hs-identifier hs-var hs-var">plusUDs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">ud_binds :: UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966564"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966564"><span class="hs-identifier hs-var">db1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: UsageDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966563"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966563"><span class="hs-identifier hs-var">calls1</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2587"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">ud_binds :: UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966562"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966562"><span class="hs-identifier hs-var">db2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: UsageDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966561"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966561"><span class="hs-identifier hs-var">calls2</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2588"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MkUD :: Bag DictBind -&gt; CallDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966564"><span class="hs-identifier hs-var">db1</span></a></span><span>    </span><span class="annot"><span class="annottext">Bag DictBind -&gt; Bag DictBind -&gt; Bag DictBind
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span>   </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966562"><span class="hs-identifier hs-var">db2</span></a></span><span>
</span><span id="line-2589"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966563"><span class="hs-identifier hs-var">calls1</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails -&gt; CallDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#unionCalls"><span class="hs-operator hs-var">`unionCalls`</span></a></span><span>  </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966561"><span class="hs-identifier hs-var">calls2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2590"></span><span>
</span><span id="line-2591"></span><span class="hs-comment">-----------------------------</span><span>
</span><span id="line-2592"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#_dictBindBndrs"><span class="hs-identifier hs-type">_dictBindBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2593"></span><span id="_dictBindBndrs"><span class="annot"><span class="annottext">_dictBindBndrs :: Bag DictBind -&gt; [Id]
</span><a href="GHC.Core.Opt.Specialise.html#_dictBindBndrs"><span class="hs-identifier hs-var hs-var">_dictBindBndrs</span></a></span></span><span> </span><span id="local-6989586621680966559"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966559"><span class="hs-identifier hs-var">dbs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(DictBind -&gt; [Id] -&gt; [Id]) -&gt; [Id] -&gt; Bag DictBind -&gt; [Id]
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">(++)</span></a></span><span> </span><span class="annot"><span class="annottext">([Id] -&gt; [Id] -&gt; [Id])
-&gt; (DictBind -&gt; [Id]) -&gt; DictBind -&gt; [Id] -&gt; [Id]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; [Id]
forall b. Bind b -&gt; [b]
</span><a href="GHC.Core.html#bindersOf"><span class="hs-identifier hs-var">bindersOf</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBind -&gt; [Id]) -&gt; (DictBind -&gt; CoreBind) -&gt; DictBind -&gt; [Id]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind -&gt; CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var hs-var">db_bind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966559"><span class="hs-identifier hs-var">dbs</span></a></span><span>
</span><span id="line-2594"></span><span>
</span><span id="line-2595"></span><span class="hs-comment">-- | Construct a 'DictBind' from a 'CoreBind'</span><span>
</span><span id="line-2596"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#mkDB"><span class="hs-identifier hs-type">mkDB</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span>
</span><span id="line-2597"></span><span id="mkDB"><span class="annot"><span class="annottext">mkDB :: CoreBind -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#mkDB"><span class="hs-identifier hs-var hs-var">mkDB</span></a></span></span><span> </span><span id="local-6989586621680966557"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966557"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DB :: CoreBind -&gt; VarSet -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#DB"><span class="hs-identifier hs-type">DB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">db_bind :: CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var">db_bind</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966557"><span class="hs-identifier hs-var">bind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">db_fvs :: VarSet
</span><a href="GHC.Core.Opt.Specialise.html#db_fvs"><span class="hs-identifier hs-var">db_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#bind_fvs"><span class="hs-identifier hs-var">bind_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966557"><span class="hs-identifier hs-var">bind</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2598"></span><span>
</span><span id="line-2599"></span><span class="hs-comment">-- | Identify the free variables of a 'CoreBind'</span><span>
</span><span id="line-2600"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#bind_fvs"><span class="hs-identifier hs-type">bind_fvs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-2601"></span><span id="bind_fvs"><span class="annot"><span class="annottext">bind_fvs :: CoreBind -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#bind_fvs"><span class="hs-identifier hs-var hs-var">bind_fvs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680966555"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966555"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680966554"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966554"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#pair_fvs"><span class="hs-identifier hs-var">pair_fvs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966555"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966554"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2602"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#bind_fvs"><span class="hs-identifier hs-var">bind_fvs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680966552"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966552"><span class="hs-identifier hs-var">prs</span></a></span></span><span class="hs-special">)</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; Id -&gt; VarSet) -&gt; VarSet -&gt; [Id] -&gt; VarSet
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#delVarSet"><span class="hs-identifier hs-var">delVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966549"><span class="hs-identifier hs-var">rhs_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966548"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2603"></span><span>                           </span><span class="hs-keyword">where</span><span>
</span><span id="line-2604"></span><span>                             </span><span id="local-6989586621680966548"><span class="annot"><span class="annottext">bndrs :: [Id]
</span><a href="#local-6989586621680966548"><span class="hs-identifier hs-var hs-var">bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Id, CoreExpr) -&gt; Id) -&gt; [(Id, CoreExpr)] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; Id
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966552"><span class="hs-identifier hs-var">prs</span></a></span><span>
</span><span id="line-2605"></span><span>                             </span><span id="local-6989586621680966549"><span class="annot"><span class="annottext">rhs_fvs :: VarSet
</span><a href="#local-6989586621680966549"><span class="hs-identifier hs-var hs-var">rhs_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[VarSet] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSets"><span class="hs-identifier hs-var">unionVarSets</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Id, CoreExpr) -&gt; VarSet) -&gt; [(Id, CoreExpr)] -&gt; [VarSet]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#pair_fvs"><span class="hs-identifier hs-var">pair_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966552"><span class="hs-identifier hs-var">prs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2606"></span><span>
</span><span id="line-2607"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#pair_fvs"><span class="hs-identifier hs-type">pair_fvs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-2608"></span><span id="pair_fvs"><span class="annot"><span class="annottext">pair_fvs :: (Id, CoreExpr) -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#pair_fvs"><span class="hs-identifier hs-var hs-var">pair_fvs</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966546"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966546"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966545"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966545"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; CoreExpr -&gt; VarSet
</span><a href="GHC.Core.FVs.html#exprSomeFreeVars"><span class="hs-identifier hs-var">exprSomeFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680966543"><span class="hs-identifier hs-var">interesting</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966545"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-2609"></span><span>                       </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet
</span><a href="GHC.Core.FVs.html#idFreeVars"><span class="hs-identifier hs-var">idFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966546"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2610"></span><span>        </span><span class="hs-comment">-- idFreeVars: don't forget variables mentioned in</span><span>
</span><span id="line-2611"></span><span>        </span><span class="hs-comment">-- the rules of the bndr.  C.f. OccAnal.addRuleUsage</span><span>
</span><span id="line-2612"></span><span>        </span><span class="hs-comment">-- Also tyvars mentioned in its type; they may not appear</span><span>
</span><span id="line-2613"></span><span>        </span><span class="hs-comment">-- in the RHS</span><span>
</span><span id="line-2614"></span><span>        </span><span class="hs-comment">--      type T a = Int</span><span>
</span><span id="line-2615"></span><span>        </span><span class="hs-comment">--      x :: T a = 3</span><span>
</span><span id="line-2616"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2617"></span><span>    </span><span class="annot"><a href="#local-6989586621680966543"><span class="hs-identifier hs-type">interesting</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#InterestingVarFun"><span class="hs-identifier hs-type">InterestingVarFun</span></a></span><span>
</span><span id="line-2618"></span><span>    </span><span id="local-6989586621680966543"><span class="annot"><span class="annottext">interesting :: Id -&gt; Bool
</span><a href="#local-6989586621680966543"><span class="hs-identifier hs-var hs-var">interesting</span></a></span></span><span> </span><span id="local-6989586621680966540"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966540"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isLocalVar"><span class="hs-identifier hs-var">isLocalVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966540"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966540"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isDFunId"><span class="hs-identifier hs-var">isDFunId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966540"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2619"></span><span>        </span><span class="hs-comment">-- Very important: include DFunIds /even/ if it is imported</span><span>
</span><span id="line-2620"></span><span>        </span><span class="hs-comment">-- Reason: See Note [Avoiding loops], the second example</span><span>
</span><span id="line-2621"></span><span>        </span><span class="hs-comment">--         involving an imported dfun.  We must know whether</span><span>
</span><span id="line-2622"></span><span>        </span><span class="hs-comment">--         a dictionary binding depends on an imported dfun,</span><span>
</span><span id="line-2623"></span><span>        </span><span class="hs-comment">--         in case we try to specialise that imported dfun</span><span>
</span><span id="line-2624"></span><span>        </span><span class="hs-comment">--         #13429 illustrates</span><span>
</span><span id="line-2625"></span><span>
</span><span id="line-2626"></span><span class="hs-comment">-- | Flatten a set of &quot;dumped&quot; 'DictBind's, and some other binding</span><span>
</span><span id="line-2627"></span><span class="hs-comment">-- pairs, into a single recursive binding.</span><span>
</span><span id="line-2628"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#recWithDumpedDicts"><span class="hs-identifier hs-type">recWithDumpedDicts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span>
</span><span id="line-2629"></span><span id="recWithDumpedDicts"><span class="annot"><span class="annottext">recWithDumpedDicts :: [(Id, CoreExpr)] -&gt; Bag DictBind -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#recWithDumpedDicts"><span class="hs-identifier hs-var hs-var">recWithDumpedDicts</span></a></span></span><span> </span><span id="local-6989586621680966539"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966539"><span class="hs-identifier hs-var">pairs</span></a></span></span><span> </span><span id="local-6989586621680966538"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966538"><span class="hs-identifier hs-var">dbs</span></a></span></span><span>
</span><span id="line-2630"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DB :: CoreBind -&gt; VarSet -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#DB"><span class="hs-identifier hs-type">DB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">db_bind :: CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var">db_bind</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966537"><span class="hs-identifier hs-var">bindings</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">db_fvs :: VarSet
</span><a href="GHC.Core.Opt.Specialise.html#db_fvs"><span class="hs-identifier hs-var">db_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966536"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2631"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2632"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680966537"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966537"><span class="hs-identifier hs-var">bindings</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966536"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966536"><span class="hs-identifier hs-var">fvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(DictBind
 -&gt; ([(Id, CoreExpr)], VarSet) -&gt; ([(Id, CoreExpr)], VarSet))
-&gt; ([(Id, CoreExpr)], VarSet)
-&gt; Bag DictBind
-&gt; ([(Id, CoreExpr)], VarSet)
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind
-&gt; ([(Id, CoreExpr)], VarSet) -&gt; ([(Id, CoreExpr)], VarSet)
</span><a href="#local-6989586621680966534"><span class="hs-identifier hs-var">add</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2633"></span><span>                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966538"><span class="hs-identifier hs-var">dbs</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; DictBind -&gt; Bag DictBind
forall a. Bag a -&gt; a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#snocBag"><span class="hs-operator hs-var">`snocBag`</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; DictBind
</span><a href="GHC.Core.Opt.Specialise.html#mkDB"><span class="hs-identifier hs-var">mkDB</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966539"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2634"></span><span>    </span><span id="local-6989586621680966534"><span class="annot"><span class="annottext">add :: DictBind
-&gt; ([(Id, CoreExpr)], VarSet) -&gt; ([(Id, CoreExpr)], VarSet)
</span><a href="#local-6989586621680966534"><span class="hs-identifier hs-var hs-var">add</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DB"><span class="hs-identifier hs-type">DB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">db_bind :: DictBind -&gt; CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var">db_bind</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966532"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966532"><span class="hs-identifier hs-var">bind</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">db_fvs :: DictBind -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#db_fvs"><span class="hs-identifier hs-var">db_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966531"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966531"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966530"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966530"><span class="hs-identifier hs-var">prs_acc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966529"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966529"><span class="hs-identifier hs-var">fvs_acc</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2635"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966532"><span class="hs-identifier hs-var">bind</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2636"></span><span>          </span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680966528"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966528"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680966527"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966527"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966528"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966527"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; [(Id, CoreExpr)] -&gt; [(Id, CoreExpr)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966530"><span class="hs-identifier hs-var">prs_acc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966526"><span class="hs-identifier hs-var">fvs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2637"></span><span>          </span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680966525"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966525"><span class="hs-identifier hs-var">prs1</span></a></span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966525"><span class="hs-identifier hs-var">prs1</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; [(Id, CoreExpr)] -&gt; [(Id, CoreExpr)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966530"><span class="hs-identifier hs-var">prs_acc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966526"><span class="hs-identifier hs-var">fvs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2638"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-2639"></span><span>        </span><span id="local-6989586621680966526"><span class="annot"><span class="annottext">fvs' :: VarSet
</span><a href="#local-6989586621680966526"><span class="hs-identifier hs-var hs-var">fvs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966529"><span class="hs-identifier hs-var">fvs_acc</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966531"><span class="hs-identifier hs-var">fvs</span></a></span><span>
</span><span id="line-2640"></span><span>
</span><span id="line-2641"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#snocDictBinds"><span class="hs-identifier hs-type">snocDictBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2642"></span><span class="hs-comment">-- Add ud_binds to the tail end of the bindings in uds</span><span>
</span><span id="line-2643"></span><span id="snocDictBinds"><span class="annot"><span class="annottext">snocDictBinds :: UsageDetails -&gt; [DictBind] -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#snocDictBinds"><span class="hs-identifier hs-var hs-var">snocDictBinds</span></a></span></span><span> </span><span id="local-6989586621680966524"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966524"><span class="hs-identifier hs-var">uds</span></a></span></span><span> </span><span id="local-6989586621680966523"><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966523"><span class="hs-identifier hs-var">dbs</span></a></span></span><span>
</span><span id="line-2644"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966524"><span class="hs-identifier hs-var">uds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var hs-var">ud_binds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966524"><span class="hs-identifier hs-var">uds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; Bag DictBind -&gt; Bag DictBind
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">[DictBind] -&gt; Bag DictBind
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966523"><span class="hs-identifier hs-var">dbs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2645"></span><span>
</span><span id="line-2646"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#consDictBind"><span class="hs-identifier hs-type">consDictBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2647"></span><span id="consDictBind"><span class="annot"><span class="annottext">consDictBind :: DictBind -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#consDictBind"><span class="hs-identifier hs-var hs-var">consDictBind</span></a></span></span><span> </span><span id="local-6989586621680966521"><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966521"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span id="local-6989586621680966520"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966520"><span class="hs-identifier hs-var">uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966520"><span class="hs-identifier hs-var">uds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966521"><span class="hs-identifier hs-var">bind</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind -&gt; Bag DictBind -&gt; Bag DictBind
forall a. a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#consBag"><span class="hs-operator hs-var">`consBag`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var hs-var">ud_binds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966520"><span class="hs-identifier hs-var">uds</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2648"></span><span>
</span><span id="line-2649"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#addDictBinds"><span class="hs-identifier hs-type">addDictBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2650"></span><span id="addDictBinds"><span class="annot"><span class="annottext">addDictBinds :: [DictBind] -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#addDictBinds"><span class="hs-identifier hs-var hs-var">addDictBinds</span></a></span></span><span> </span><span id="local-6989586621680966518"><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966518"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621680966517"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966517"><span class="hs-identifier hs-var">uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966517"><span class="hs-identifier hs-var">uds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[DictBind] -&gt; Bag DictBind
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[DictBind]
</span><a href="#local-6989586621680966518"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; Bag DictBind -&gt; Bag DictBind
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var hs-var">ud_binds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966517"><span class="hs-identifier hs-var">uds</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2651"></span><span>
</span><span id="line-2652"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#snocDictBind"><span class="hs-identifier hs-type">snocDictBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span>
</span><span id="line-2653"></span><span id="snocDictBind"><span class="annot"><span class="annottext">snocDictBind :: UsageDetails -&gt; DictBind -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#snocDictBind"><span class="hs-identifier hs-var hs-var">snocDictBind</span></a></span></span><span> </span><span id="local-6989586621680966516"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966516"><span class="hs-identifier hs-var">uds</span></a></span></span><span> </span><span id="local-6989586621680966515"><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966515"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966516"><span class="hs-identifier hs-var">uds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var hs-var">ud_binds</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966516"><span class="hs-identifier hs-var">uds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; DictBind -&gt; Bag DictBind
forall a. Bag a -&gt; a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#snocBag"><span class="hs-operator hs-var">`snocBag`</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966515"><span class="hs-identifier hs-var">bind</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2654"></span><span>
</span><span id="line-2655"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#wrapDictBinds"><span class="hs-identifier hs-type">wrapDictBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2656"></span><span id="wrapDictBinds"><span class="annot"><span class="annottext">wrapDictBinds :: Bag DictBind -&gt; CoreProgram -&gt; CoreProgram
</span><a href="GHC.Core.Opt.Specialise.html#wrapDictBinds"><span class="hs-identifier hs-var hs-var">wrapDictBinds</span></a></span></span><span> </span><span id="local-6989586621680966514"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966514"><span class="hs-identifier hs-var">dbs</span></a></span></span><span> </span><span id="local-6989586621680966513"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680966513"><span class="hs-identifier hs-var">binds</span></a></span></span><span>
</span><span id="line-2657"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(DictBind -&gt; CoreProgram -&gt; CoreProgram)
-&gt; CoreProgram -&gt; Bag DictBind -&gt; CoreProgram
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind -&gt; CoreProgram -&gt; CoreProgram
</span><a href="#local-6989586621680966512"><span class="hs-identifier hs-var">add</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680966513"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966514"><span class="hs-identifier hs-var">dbs</span></a></span><span>
</span><span id="line-2658"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2659"></span><span>    </span><span id="local-6989586621680966512"><span class="annot"><span class="annottext">add :: DictBind -&gt; CoreProgram -&gt; CoreProgram
</span><a href="#local-6989586621680966512"><span class="hs-identifier hs-var hs-var">add</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DB"><span class="hs-identifier hs-type">DB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">db_bind :: DictBind -&gt; CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var">db_bind</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966511"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966511"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680966510"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680966510"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966511"><span class="hs-identifier hs-var">bind</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; CoreProgram -&gt; CoreProgram
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680966510"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-2660"></span><span>
</span><span id="line-2661"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#wrapDictBindsE"><span class="hs-identifier hs-type">wrapDictBindsE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-2662"></span><span id="wrapDictBindsE"><span class="annot"><span class="annottext">wrapDictBindsE :: Bag DictBind -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Specialise.html#wrapDictBindsE"><span class="hs-identifier hs-var hs-var">wrapDictBindsE</span></a></span></span><span> </span><span id="local-6989586621680966509"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966509"><span class="hs-identifier hs-var">dbs</span></a></span></span><span> </span><span id="local-6989586621680966508"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966508"><span class="hs-identifier hs-var">expr</span></a></span></span><span>
</span><span id="line-2663"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(DictBind -&gt; CoreExpr -&gt; CoreExpr)
-&gt; CoreExpr -&gt; Bag DictBind -&gt; CoreExpr
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind -&gt; CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680966507"><span class="hs-identifier hs-var">add</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966508"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966509"><span class="hs-identifier hs-var">dbs</span></a></span><span>
</span><span id="line-2664"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2665"></span><span>    </span><span id="local-6989586621680966507"><span class="annot"><span class="annottext">add :: DictBind -&gt; CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680966507"><span class="hs-identifier hs-var hs-var">add</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DB"><span class="hs-identifier hs-type">DB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">db_bind :: DictBind -&gt; CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var">db_bind</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966506"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966506"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680966505"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966505"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; CoreExpr -&gt; CoreExpr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966506"><span class="hs-identifier hs-var">bind</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966505"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-2666"></span><span>
</span><span id="line-2667"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-2668"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#dumpUDs"><span class="hs-identifier hs-type">dumpUDs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2669"></span><span class="hs-comment">-- Used at a lambda or case binder; just dump anything mentioning the binder</span><span>
</span><span id="line-2670"></span><span id="dumpUDs"><span class="annot"><span class="annottext">dumpUDs :: [Id] -&gt; UsageDetails -&gt; (UsageDetails, Bag DictBind)
</span><a href="GHC.Core.Opt.Specialise.html#dumpUDs"><span class="hs-identifier hs-var hs-var">dumpUDs</span></a></span></span><span> </span><span id="local-6989586621680966503"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966503"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span id="local-6989586621680966502"><span class="annot"><span class="annottext">uds :: UsageDetails
</span><a href="#local-6989586621680966502"><span class="hs-identifier hs-var">uds</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966501"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966501"><span class="hs-identifier hs-var">orig_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: UsageDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966500"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966500"><span class="hs-identifier hs-var">orig_calls</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2671"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966503"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966502"><span class="hs-identifier hs-var">uds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Common in case alternatives</span><span>
</span><span id="line-2672"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;dumpUDs&quot; (ppr bndrs $$ ppr free_uds $$ ppr dump_dbs) $</span><span>
</span><span id="line-2673"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966499"><span class="hs-identifier hs-var">free_uds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966498"><span class="hs-identifier hs-var">dump_dbs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2674"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2675"></span><span>    </span><span id="local-6989586621680966499"><span class="annot"><span class="annottext">free_uds :: UsageDetails
</span><a href="#local-6989586621680966499"><span class="hs-identifier hs-var hs-var">free_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MkUD :: Bag DictBind -&gt; CallDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966497"><span class="hs-identifier hs-var">free_dbs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966496"><span class="hs-identifier hs-var">free_calls</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2676"></span><span>    </span><span id="local-6989586621680966495"><span class="annot"><span class="annottext">bndr_set :: VarSet
</span><a href="#local-6989586621680966495"><span class="hs-identifier hs-var hs-var">bndr_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966503"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2677"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680966497"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966497"><span class="hs-identifier hs-var">free_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966498"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966498"><span class="hs-identifier hs-var">dump_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966494"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966494"><span class="hs-identifier hs-var">dump_set</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; VarSet -&gt; (Bag DictBind, Bag DictBind, VarSet)
</span><a href="GHC.Core.Opt.Specialise.html#splitDictBinds"><span class="hs-identifier hs-var">splitDictBinds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966501"><span class="hs-identifier hs-var">orig_dbs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966495"><span class="hs-identifier hs-var">bndr_set</span></a></span><span>
</span><span id="line-2678"></span><span>    </span><span id="local-6989586621680966496"><span class="annot"><span class="annottext">free_calls :: CallDetails
</span><a href="#local-6989586621680966496"><span class="hs-identifier hs-var hs-var">free_calls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; CallDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#deleteCallsMentioning"><span class="hs-identifier hs-var">deleteCallsMentioning</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966494"><span class="hs-identifier hs-var">dump_set</span></a></span><span> </span><span class="annot"><span class="annottext">(CallDetails -&gt; CallDetails) -&gt; CallDetails -&gt; CallDetails
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>   </span><span class="hs-comment">-- Drop calls mentioning bndr_set on the floor</span><span>
</span><span id="line-2679"></span><span>                 </span><span class="annot"><span class="annottext">[Id] -&gt; CallDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#deleteCallsFor"><span class="hs-identifier hs-var">deleteCallsFor</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966503"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966500"><span class="hs-identifier hs-var">orig_calls</span></a></span><span>    </span><span class="hs-comment">-- Discard calls for bndr_set; there should be</span><span>
</span><span id="line-2680"></span><span>                                                    </span><span class="hs-comment">-- no calls for any of the dicts in dump_dbs</span><span>
</span><span id="line-2681"></span><span>
</span><span id="line-2682"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#dumpBindUDs"><span class="hs-identifier hs-type">dumpBindUDs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span>
</span><span id="line-2683"></span><span class="hs-comment">-- Used at a let(rec) binding.</span><span>
</span><span id="line-2684"></span><span class="hs-comment">-- We return a boolean indicating whether the binding itself is mentioned,</span><span>
</span><span id="line-2685"></span><span class="hs-comment">-- directly or indirectly, by any of the ud_calls; in that case we want to</span><span>
</span><span id="line-2686"></span><span class="hs-comment">-- float the binding itself;</span><span>
</span><span id="line-2687"></span><span class="hs-comment">-- See Note [Floated dictionary bindings]</span><span>
</span><span id="line-2688"></span><span id="dumpBindUDs"><span class="annot"><span class="annottext">dumpBindUDs :: [Id] -&gt; UsageDetails -&gt; (UsageDetails, Bag DictBind, Bool)
</span><a href="GHC.Core.Opt.Specialise.html#dumpBindUDs"><span class="hs-identifier hs-var hs-var">dumpBindUDs</span></a></span></span><span> </span><span id="local-6989586621680966490"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966490"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966489"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966489"><span class="hs-identifier hs-var">orig_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: UsageDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966488"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966488"><span class="hs-identifier hs-var">orig_calls</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2689"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;dumpBindUDs&quot; (ppr bndrs $$ ppr free_uds $$ ppr dump_dbs) $</span><span>
</span><span id="line-2690"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966487"><span class="hs-identifier hs-var">free_uds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966486"><span class="hs-identifier hs-var">dump_dbs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680966485"><span class="hs-identifier hs-var">float_all</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2691"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2692"></span><span>    </span><span id="local-6989586621680966487"><span class="annot"><span class="annottext">free_uds :: UsageDetails
</span><a href="#local-6989586621680966487"><span class="hs-identifier hs-var hs-var">free_uds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MkUD :: Bag DictBind -&gt; CallDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966484"><span class="hs-identifier hs-var">free_dbs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966483"><span class="hs-identifier hs-var">free_calls</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2693"></span><span>    </span><span id="local-6989586621680966482"><span class="annot"><span class="annottext">bndr_set :: VarSet
</span><a href="#local-6989586621680966482"><span class="hs-identifier hs-var hs-var">bndr_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966490"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-2694"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680966484"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966484"><span class="hs-identifier hs-var">free_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966486"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966486"><span class="hs-identifier hs-var">dump_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966481"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966481"><span class="hs-identifier hs-var">dump_set</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; VarSet -&gt; (Bag DictBind, Bag DictBind, VarSet)
</span><a href="GHC.Core.Opt.Specialise.html#splitDictBinds"><span class="hs-identifier hs-var">splitDictBinds</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966489"><span class="hs-identifier hs-var">orig_dbs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966482"><span class="hs-identifier hs-var">bndr_set</span></a></span><span>
</span><span id="line-2695"></span><span>    </span><span id="local-6989586621680966483"><span class="annot"><span class="annottext">free_calls :: CallDetails
</span><a href="#local-6989586621680966483"><span class="hs-identifier hs-var hs-var">free_calls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; CallDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#deleteCallsFor"><span class="hs-identifier hs-var">deleteCallsFor</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966490"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966488"><span class="hs-identifier hs-var">orig_calls</span></a></span><span>
</span><span id="line-2696"></span><span>    </span><span id="local-6989586621680966485"><span class="annot"><span class="annottext">float_all :: Bool
</span><a href="#local-6989586621680966485"><span class="hs-identifier hs-var hs-var">float_all</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966481"><span class="hs-identifier hs-var">dump_set</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#intersectsVarSet"><span class="hs-operator hs-var">`intersectsVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#callDetailsFVs"><span class="hs-identifier hs-var">callDetailsFVs</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966483"><span class="hs-identifier hs-var">free_calls</span></a></span><span>
</span><span id="line-2697"></span><span>
</span><span id="line-2698"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#callsForMe"><span class="hs-identifier hs-type">callsForMe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfo"><span class="hs-identifier hs-type">CallInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2699"></span><span id="callsForMe"><span class="annot"><span class="annottext">callsForMe :: Id -&gt; UsageDetails -&gt; (UsageDetails, [CallInfo])
</span><a href="GHC.Core.Opt.Specialise.html#callsForMe"><span class="hs-identifier hs-var hs-var">callsForMe</span></a></span></span><span> </span><span id="local-6989586621680966479"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966479"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: UsageDetails -&gt; Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966478"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966478"><span class="hs-identifier hs-var">orig_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: UsageDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966477"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966477"><span class="hs-identifier hs-var">orig_calls</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2700"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace (&quot;callsForMe&quot;)</span><span>
</span><span id="line-2701"></span><span>    </span><span class="hs-comment">--          (vcat [ppr fn,</span><span>
</span><span id="line-2702"></span><span>    </span><span class="hs-comment">--                 text &quot;Orig dbs =&quot;     &lt;+&gt; ppr (_dictBindBndrs orig_dbs),</span><span>
</span><span id="line-2703"></span><span>    </span><span class="hs-comment">--                 text &quot;Orig calls =&quot;   &lt;+&gt; ppr orig_calls,</span><span>
</span><span id="line-2704"></span><span>    </span><span class="hs-comment">--                 text &quot;Dep set =&quot;      &lt;+&gt; ppr dep_set,</span><span>
</span><span id="line-2705"></span><span>    </span><span class="hs-comment">--                 text &quot;Calls for me =&quot; &lt;+&gt; ppr calls_for_me]) $</span><span>
</span><span id="line-2706"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966476"><span class="hs-identifier hs-var">uds_without_me</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CallInfo]
</span><a href="#local-6989586621680966475"><span class="hs-identifier hs-var">calls_for_me</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2707"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2708"></span><span>    </span><span id="local-6989586621680966476"><span class="annot"><span class="annottext">uds_without_me :: UsageDetails
</span><a href="#local-6989586621680966476"><span class="hs-identifier hs-var hs-var">uds_without_me</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MkUD :: Bag DictBind -&gt; CallDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#MkUD"><span class="hs-identifier hs-type">MkUD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ud_binds :: Bag DictBind
</span><a href="GHC.Core.Opt.Specialise.html#ud_binds"><span class="hs-identifier hs-var">ud_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966478"><span class="hs-identifier hs-var">orig_dbs</span></a></span><span>
</span><span id="line-2709"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ud_calls :: CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#ud_calls"><span class="hs-identifier hs-var">ud_calls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallDetails -&gt; Id -&gt; CallDetails
forall a. DVarEnv a -&gt; Id -&gt; DVarEnv a
</span><a href="GHC.Types.Var.Env.html#delDVarEnv"><span class="hs-identifier hs-var">delDVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966477"><span class="hs-identifier hs-var">orig_calls</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966479"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2710"></span><span>    </span><span id="local-6989586621680966475"><span class="annot"><span class="annottext">calls_for_me :: [CallInfo]
</span><a href="#local-6989586621680966475"><span class="hs-identifier hs-var hs-var">calls_for_me</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CallDetails -&gt; Id -&gt; Maybe CallInfoSet
forall a. DVarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupDVarEnv"><span class="hs-identifier hs-var">lookupDVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966477"><span class="hs-identifier hs-var">orig_calls</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966479"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2711"></span><span>                        </span><span class="annot"><span class="annottext">Maybe CallInfoSet
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-2712"></span><span>                        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680966472"><span class="annot"><span class="annottext">CallInfoSet
</span><a href="#local-6989586621680966472"><span class="hs-identifier hs-var">cis</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CallInfoSet -&gt; Bag DictBind -&gt; [CallInfo]
</span><a href="GHC.Core.Opt.Specialise.html#filterCalls"><span class="hs-identifier hs-var">filterCalls</span></a></span><span> </span><span class="annot"><span class="annottext">CallInfoSet
</span><a href="#local-6989586621680966472"><span class="hs-identifier hs-var">cis</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966478"><span class="hs-identifier hs-var">orig_dbs</span></a></span><span>
</span><span id="line-2713"></span><span>         </span><span class="hs-comment">-- filterCalls: drop calls that (directly or indirectly)</span><span>
</span><span id="line-2714"></span><span>         </span><span class="hs-comment">-- refer to fn.  See Note [Avoiding loops]</span><span>
</span><span id="line-2715"></span><span>
</span><span id="line-2716"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-2717"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#filterCalls"><span class="hs-identifier hs-type">filterCalls</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfoSet"><span class="hs-identifier hs-type">CallInfoSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallInfo"><span class="hs-identifier hs-type">CallInfo</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2718"></span><span class="hs-comment">-- See Note [Avoiding loops]</span><span>
</span><span id="line-2719"></span><span id="filterCalls"><span class="annot"><span class="annottext">filterCalls :: CallInfoSet -&gt; Bag DictBind -&gt; [CallInfo]
</span><a href="GHC.Core.Opt.Specialise.html#filterCalls"><span class="hs-identifier hs-var hs-var">filterCalls</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CIS"><span class="hs-identifier hs-type">CIS</span></a></span><span> </span><span id="local-6989586621680966471"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966471"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621680966470"><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966470"><span class="hs-identifier hs-var">call_bag</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680966469"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966469"><span class="hs-identifier hs-var">dbs</span></a></span></span><span>
</span><span id="line-2720"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CallInfo -&gt; Bool) -&gt; [CallInfo] -&gt; [CallInfo]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">CallInfo -&gt; Bool
</span><a href="#local-6989586621680966468"><span class="hs-identifier hs-var">ok_call</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag CallInfo -&gt; [CallInfo]
forall a. Bag a -&gt; [a]
</span><a href="GHC.Data.Bag.html#bagToList"><span class="hs-identifier hs-var">bagToList</span></a></span><span> </span><span class="annot"><span class="annottext">Bag CallInfo
</span><a href="#local-6989586621680966470"><span class="hs-identifier hs-var">call_bag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2721"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2722"></span><span>    </span><span id="local-6989586621680966466"><span class="annot"><span class="annottext">dump_set :: VarSet
</span><a href="#local-6989586621680966466"><span class="hs-identifier hs-var hs-var">dump_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; DictBind -&gt; VarSet) -&gt; VarSet -&gt; Bag DictBind -&gt; VarSet
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; DictBind -&gt; VarSet
</span><a href="#local-6989586621680966465"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unitVarSet"><span class="hs-identifier hs-var">unitVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966471"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966469"><span class="hs-identifier hs-var">dbs</span></a></span><span>
</span><span id="line-2723"></span><span>      </span><span class="hs-comment">-- This dump-set could also be computed by splitDictBinds</span><span>
</span><span id="line-2724"></span><span>      </span><span class="hs-comment">--   (_,_,dump_set) = splitDictBinds dbs {fn}</span><span>
</span><span id="line-2725"></span><span>      </span><span class="hs-comment">-- But this variant is shorter</span><span>
</span><span id="line-2726"></span><span>
</span><span id="line-2727"></span><span>    </span><span id="local-6989586621680966465"><span class="annot"><span class="annottext">go :: VarSet -&gt; DictBind -&gt; VarSet
</span><a href="#local-6989586621680966465"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680966464"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966464"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DB"><span class="hs-identifier hs-type">DB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">db_bind :: DictBind -&gt; CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var">db_bind</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966463"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966463"><span class="hs-identifier hs-var">bind</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">db_fvs :: DictBind -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#db_fvs"><span class="hs-identifier hs-var">db_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966462"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966462"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2728"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966462"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#intersectsVarSet"><span class="hs-operator hs-var">`intersectsVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966464"><span class="hs-identifier hs-var">so_far</span></a></span><span>
</span><span id="line-2729"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSetList"><span class="hs-identifier hs-var">extendVarSetList</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966464"><span class="hs-identifier hs-var">so_far</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBind -&gt; [Id]
forall b. Bind b -&gt; [b]
</span><a href="GHC.Core.html#bindersOf"><span class="hs-identifier hs-var">bindersOf</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966463"><span class="hs-identifier hs-var">bind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2730"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966464"><span class="hs-identifier hs-var">so_far</span></a></span><span>
</span><span id="line-2731"></span><span>
</span><span id="line-2732"></span><span>    </span><span id="local-6989586621680966468"><span class="annot"><span class="annottext">ok_call :: CallInfo -&gt; Bool
</span><a href="#local-6989586621680966468"><span class="hs-identifier hs-var hs-var">ok_call</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CI"><span class="hs-identifier hs-type">CI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ci_fvs :: CallInfo -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#ci_fvs"><span class="hs-identifier hs-var">ci_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966461"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966461"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966461"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#disjointVarSet"><span class="hs-operator hs-var">`disjointVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966466"><span class="hs-identifier hs-var">dump_set</span></a></span><span>
</span><span id="line-2733"></span><span>
</span><span id="line-2734"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-2735"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#splitDictBinds"><span class="hs-identifier hs-type">splitDictBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#IdSet"><span class="hs-identifier hs-type">IdSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DictBind"><span class="hs-identifier hs-type">DictBind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#IdSet"><span class="hs-identifier hs-type">IdSet</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2736"></span><span class="hs-comment">-- splitDictBinds dbs bndrs returns</span><span>
</span><span id="line-2737"></span><span class="hs-comment">--   (free_dbs, dump_dbs, dump_set)</span><span>
</span><span id="line-2738"></span><span class="hs-comment">-- where</span><span>
</span><span id="line-2739"></span><span class="hs-comment">--   * dump_dbs depends, transitively on bndrs</span><span>
</span><span id="line-2740"></span><span class="hs-comment">--   * free_dbs does not depend on bndrs</span><span>
</span><span id="line-2741"></span><span class="hs-comment">--   * dump_set = bndrs `union` bndrs(dump_dbs)</span><span>
</span><span id="line-2742"></span><span id="splitDictBinds"><span class="annot"><span class="annottext">splitDictBinds :: Bag DictBind -&gt; VarSet -&gt; (Bag DictBind, Bag DictBind, VarSet)
</span><a href="GHC.Core.Opt.Specialise.html#splitDictBinds"><span class="hs-identifier hs-var hs-var">splitDictBinds</span></a></span></span><span> </span><span id="local-6989586621680966459"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966459"><span class="hs-identifier hs-var">dbs</span></a></span></span><span> </span><span id="local-6989586621680966458"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966458"><span class="hs-identifier hs-var">bndr_set</span></a></span></span><span>
</span><span id="line-2743"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Bag DictBind, Bag DictBind, VarSet)
 -&gt; DictBind -&gt; (Bag DictBind, Bag DictBind, VarSet))
-&gt; (Bag DictBind, Bag DictBind, VarSet)
-&gt; Bag DictBind
-&gt; (Bag DictBind, Bag DictBind, VarSet)
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">(Bag DictBind, Bag DictBind, VarSet)
-&gt; DictBind -&gt; (Bag DictBind, Bag DictBind, VarSet)
</span><a href="#local-6989586621680966457"><span class="hs-identifier hs-var">split_db</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag DictBind
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966458"><span class="hs-identifier hs-var">bndr_set</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966459"><span class="hs-identifier hs-var">dbs</span></a></span><span>
</span><span id="line-2744"></span><span>                </span><span class="hs-comment">-- Important that it's foldl' not foldr;</span><span>
</span><span id="line-2745"></span><span>                </span><span class="hs-comment">-- we're accumulating the set of dumped ids in dump_set</span><span>
</span><span id="line-2746"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-2747"></span><span>    </span><span id="local-6989586621680966457"><span class="annot"><span class="annottext">split_db :: (Bag DictBind, Bag DictBind, VarSet)
-&gt; DictBind -&gt; (Bag DictBind, Bag DictBind, VarSet)
</span><a href="#local-6989586621680966457"><span class="hs-identifier hs-var hs-var">split_db</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966456"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966456"><span class="hs-identifier hs-var">free_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966455"><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966455"><span class="hs-identifier hs-var">dump_dbs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966454"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966454"><span class="hs-identifier hs-var">dump_idset</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680966453"><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966453"><span class="hs-identifier hs-var">db</span></a></span></span><span>
</span><span id="line-2748"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#DB"><span class="hs-identifier hs-type">DB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">db_bind :: DictBind -&gt; CoreBind
</span><a href="GHC.Core.Opt.Specialise.html#db_bind"><span class="hs-identifier hs-var">db_bind</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966452"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966452"><span class="hs-identifier hs-var">bind</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">db_fvs :: DictBind -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#db_fvs"><span class="hs-identifier hs-var">db_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966451"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966451"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966453"><span class="hs-identifier hs-var">db</span></a></span><span>
</span><span id="line-2749"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966454"><span class="hs-identifier hs-var">dump_idset</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#intersectsVarSet"><span class="hs-operator hs-var">`intersectsVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966451"><span class="hs-identifier hs-var">fvs</span></a></span><span>     </span><span class="hs-comment">-- Dump it</span><span>
</span><span id="line-2750"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966456"><span class="hs-identifier hs-var">free_dbs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966455"><span class="hs-identifier hs-var">dump_dbs</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; DictBind -&gt; Bag DictBind
forall a. Bag a -&gt; a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#snocBag"><span class="hs-operator hs-var">`snocBag`</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966453"><span class="hs-identifier hs-var">db</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-2751"></span><span>           </span><span class="annot"><span class="annottext">VarSet -&gt; [Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSetList"><span class="hs-identifier hs-var">extendVarSetList</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966454"><span class="hs-identifier hs-var">dump_idset</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBind -&gt; [Id]
forall b. Bind b -&gt; [b]
</span><a href="GHC.Core.html#bindersOf"><span class="hs-identifier hs-var">bindersOf</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680966452"><span class="hs-identifier hs-var">bind</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2752"></span><span>
</span><span id="line-2753"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-comment">-- Don't dump it</span><span>
</span><span id="line-2754"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966456"><span class="hs-identifier hs-var">free_dbs</span></a></span><span> </span><span class="annot"><span class="annottext">Bag DictBind -&gt; DictBind -&gt; Bag DictBind
forall a. Bag a -&gt; a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#snocBag"><span class="hs-operator hs-var">`snocBag`</span></a></span><span> </span><span class="annot"><span class="annottext">DictBind
</span><a href="#local-6989586621680966453"><span class="hs-identifier hs-var">db</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag DictBind
</span><a href="#local-6989586621680966455"><span class="hs-identifier hs-var">dump_dbs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966454"><span class="hs-identifier hs-var">dump_idset</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2755"></span><span>
</span><span id="line-2756"></span><span>
</span><span id="line-2757"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-2758"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#deleteCallsMentioning"><span class="hs-identifier hs-type">deleteCallsMentioning</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-type">CallDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-type">CallDetails</span></a></span><span>
</span><span id="line-2759"></span><span class="hs-comment">-- Remove calls *mentioning* bs in any way</span><span>
</span><span id="line-2760"></span><span id="deleteCallsMentioning"><span class="annot"><span class="annottext">deleteCallsMentioning :: VarSet -&gt; CallDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#deleteCallsMentioning"><span class="hs-identifier hs-var hs-var">deleteCallsMentioning</span></a></span></span><span> </span><span id="local-6989586621680966450"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966450"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span id="local-6989586621680966449"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966449"><span class="hs-identifier hs-var">calls</span></a></span></span><span>
</span><span id="line-2761"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CallInfoSet -&gt; CallInfoSet) -&gt; CallDetails -&gt; CallDetails
forall a b. (a -&gt; b) -&gt; DVarEnv a -&gt; DVarEnv b
</span><a href="GHC.Types.Var.Env.html#mapDVarEnv"><span class="hs-identifier hs-var">mapDVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CallInfo -&gt; Bool) -&gt; CallInfoSet -&gt; CallInfoSet
</span><a href="GHC.Core.Opt.Specialise.html#ciSetFilter"><span class="hs-identifier hs-var">ciSetFilter</span></a></span><span> </span><span class="annot"><span class="annottext">CallInfo -&gt; Bool
</span><a href="#local-6989586621680966447"><span class="hs-identifier hs-var">keep_call</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966449"><span class="hs-identifier hs-var">calls</span></a></span><span>
</span><span id="line-2762"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2763"></span><span>    </span><span id="local-6989586621680966447"><span class="annot"><span class="annottext">keep_call :: CallInfo -&gt; Bool
</span><a href="#local-6989586621680966447"><span class="hs-identifier hs-var hs-var">keep_call</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CI"><span class="hs-identifier hs-type">CI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ci_fvs :: CallInfo -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#ci_fvs"><span class="hs-identifier hs-var">ci_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966446"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966446"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966446"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#disjointVarSet"><span class="hs-operator hs-var">`disjointVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966450"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-2764"></span><span>
</span><span id="line-2765"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#deleteCallsFor"><span class="hs-identifier hs-type">deleteCallsFor</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-type">CallDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#CallDetails"><span class="hs-identifier hs-type">CallDetails</span></a></span><span>
</span><span id="line-2766"></span><span class="hs-comment">-- Remove calls *for* bs</span><span>
</span><span id="line-2767"></span><span id="deleteCallsFor"><span class="annot"><span class="annottext">deleteCallsFor :: [Id] -&gt; CallDetails -&gt; CallDetails
</span><a href="GHC.Core.Opt.Specialise.html#deleteCallsFor"><span class="hs-identifier hs-var hs-var">deleteCallsFor</span></a></span></span><span> </span><span id="local-6989586621680966445"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966445"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span id="local-6989586621680966444"><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966444"><span class="hs-identifier hs-var">calls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallDetails -&gt; [Id] -&gt; CallDetails
forall a. DVarEnv a -&gt; [Id] -&gt; DVarEnv a
</span><a href="GHC.Types.Var.Env.html#delDVarEnvList"><span class="hs-identifier hs-var">delDVarEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">CallDetails
</span><a href="#local-6989586621680966444"><span class="hs-identifier hs-var">calls</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966445"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-2768"></span><span>
</span><span id="line-2769"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsubsection{Boring helper functions}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-2776"></span><span>
</span><span id="line-2777"></span><span class="hs-keyword">newtype</span><span> </span><span id="SpecM"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-var">SpecM</span></a></span></span><span> </span><span id="local-6989586621680967638"><span class="annot"><a href="#local-6989586621680967638"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="SpecM"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-var">SpecM</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Monad.State.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecState"><span class="hs-identifier hs-type">SpecState</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680967638"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966436"><span id="local-6989586621680966440"><span class="annot"><span class="annottext">(forall a b. (a -&gt; b) -&gt; SpecM a -&gt; SpecM b)
-&gt; (forall a b. a -&gt; SpecM b -&gt; SpecM a) -&gt; Functor SpecM
forall a b. a -&gt; SpecM b -&gt; SpecM a
forall a b. (a -&gt; b) -&gt; SpecM a -&gt; SpecM b
forall (f :: * -&gt; *).
(forall a b. (a -&gt; b) -&gt; f a -&gt; f b)
-&gt; (forall a b. a -&gt; f b -&gt; f a) -&gt; Functor f
&lt;$ :: forall a b. a -&gt; SpecM b -&gt; SpecM a
$c&lt;$ :: forall a b. a -&gt; SpecM b -&gt; SpecM a
fmap :: forall a b. (a -&gt; b) -&gt; SpecM a -&gt; SpecM b
$cfmap :: forall a b. (a -&gt; b) -&gt; SpecM a -&gt; SpecM b
</span><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Functor</span></a></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-2778"></span><span>
</span><span id="line-2779"></span><span class="hs-keyword">data</span><span> </span><span id="SpecState"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecState"><span class="hs-identifier hs-var">SpecState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="SpecState"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecState"><span class="hs-identifier hs-var">SpecState</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-2780"></span><span>                     </span><span id="spec_uniq_supply"><span class="annot"><span class="annottext">SpecState -&gt; UniqSupply
</span><a href="GHC.Core.Opt.Specialise.html#spec_uniq_supply"><span class="hs-identifier hs-var hs-var">spec_uniq_supply</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSupply"><span class="hs-identifier hs-type">UniqSupply</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-2781"></span><span>                     </span><span id="spec_module"><span class="annot"><span class="annottext">SpecState -&gt; Module
</span><a href="GHC.Core.Opt.Specialise.html#spec_module"><span class="hs-identifier hs-var hs-var">spec_module</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier hs-type">Module</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-2782"></span><span>                     </span><span id="spec_dflags"><span class="annot"><span class="annottext">SpecState -&gt; DynFlags
</span><a href="GHC.Core.Opt.Specialise.html#spec_dflags"><span class="hs-identifier hs-var hs-var">spec_dflags</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-2783"></span><span>                 </span><span class="hs-special">}</span><span>
</span><span id="line-2784"></span><span>
</span><span id="line-2785"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680966419"><span id="local-6989586621680966421"><span id="local-6989586621680966423"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2786"></span><span>    </span><span id="local-6989586621680966415"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; SpecM a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span id="local-6989586621680966414"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680966414"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State SpecState a -&gt; SpecM a
forall a. State SpecState a -&gt; SpecM a
</span><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-var">SpecM</span></a></span><span> </span><span class="annot"><span class="annottext">(State SpecState a -&gt; SpecM a) -&gt; State SpecState a -&gt; SpecM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; State SpecState a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680966414"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-2787"></span><span>    </span><span id="local-6989586621680966412"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. SpecM (a -&gt; b) -&gt; SpecM a -&gt; SpecM b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;*&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecM (a -&gt; b) -&gt; SpecM a -&gt; SpecM b
forall (m :: * -&gt; *) a b. Monad m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#ap"><span class="hs-identifier hs-var">ap</span></a></span><span>
</span><span id="line-2788"></span><span>
</span><span id="line-2789"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680966404"><span id="local-6989586621680966406"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2790"></span><span>    </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span id="local-6989586621680966401"><span class="annot"><span class="annottext">State SpecState a
</span><a href="#local-6989586621680966401"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621680966400"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. SpecM a -&gt; (a -&gt; SpecM b) -&gt; SpecM b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621680966399"><span class="annot"><span class="annottext">a -&gt; SpecM b
</span><a href="#local-6989586621680966399"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State SpecState b -&gt; SpecM b
forall a. State SpecState a -&gt; SpecM a
</span><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-var">SpecM</span></a></span><span> </span><span class="annot"><span class="annottext">(State SpecState b -&gt; SpecM b) -&gt; State SpecState b -&gt; SpecM b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621680966398"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680966398"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">State SpecState a
</span><a href="#local-6989586621680966401"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-2791"></span><span>                               </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">a -&gt; SpecM b
</span><a href="#local-6989586621680966399"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680966398"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2792"></span><span>                                   </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span id="local-6989586621680966397"><span class="annot"><span class="annottext">State SpecState b
</span><a href="#local-6989586621680966397"><span class="hs-identifier hs-var">z</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-2793"></span><span>                                       </span><span class="annot"><span class="annottext">State SpecState b
</span><a href="#local-6989586621680966397"><span class="hs-identifier hs-var">z</span></a></span><span>
</span><span id="line-2794"></span><span>
</span><span id="line-2795"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fail.html#MonadFail"><span class="hs-identifier hs-type">MonadFail</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2796"></span><span>   </span><span id="local-6989586621680966390"><span class="annot"><span class="annottext">fail :: forall a. String -&gt; SpecM a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var hs-var hs-var hs-var">fail</span></a></span></span><span> </span><span id="local-6989586621680966389"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680966389"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State SpecState a -&gt; SpecM a
forall a. State SpecState a -&gt; SpecM a
</span><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-var">SpecM</span></a></span><span> </span><span class="annot"><span class="annottext">(State SpecState a -&gt; SpecM a) -&gt; State SpecState a -&gt; SpecM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; State SpecState a
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680966389"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-2797"></span><span>
</span><span id="line-2798"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680966382"><span class="annot"><a href="GHC.Types.Unique.Supply.html#MonadUnique"><span class="hs-identifier hs-type">MonadUnique</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2799"></span><span>    </span><span id="local-6989586621680966377"><span class="annot"><span class="annottext">getUniqueSupplyM :: SpecM UniqSupply
</span><a href="GHC.Types.Unique.Supply.html#getUniqueSupplyM"><span class="hs-identifier hs-var hs-var hs-var hs-var">getUniqueSupplyM</span></a></span></span><span>
</span><span id="line-2800"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State SpecState UniqSupply -&gt; SpecM UniqSupply
forall a. State SpecState a -&gt; SpecM a
</span><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-var">SpecM</span></a></span><span> </span><span class="annot"><span class="annottext">(State SpecState UniqSupply -&gt; SpecM UniqSupply)
-&gt; State SpecState UniqSupply -&gt; SpecM UniqSupply
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621680966375"><span class="annot"><span class="annottext">SpecState
</span><a href="#local-6989586621680966375"><span class="hs-identifier hs-var">st</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">State SpecState SpecState
forall s. State s s
</span><a href="GHC.Utils.Monad.State.html#get"><span class="hs-identifier hs-var">get</span></a></span><span>
</span><span id="line-2801"></span><span>                     </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966373"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966373"><span class="hs-identifier hs-var">us1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966372"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966372"><span class="hs-identifier hs-var">us2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSupply -&gt; (UniqSupply, UniqSupply)
</span><a href="GHC.Types.Unique.Supply.html#splitUniqSupply"><span class="hs-identifier hs-var">splitUniqSupply</span></a></span><span> </span><span class="annot"><span class="annottext">(UniqSupply -&gt; (UniqSupply, UniqSupply))
-&gt; UniqSupply -&gt; (UniqSupply, UniqSupply)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SpecState -&gt; UniqSupply
</span><a href="GHC.Core.Opt.Specialise.html#spec_uniq_supply"><span class="hs-identifier hs-var hs-var">spec_uniq_supply</span></a></span><span> </span><span class="annot"><span class="annottext">SpecState
</span><a href="#local-6989586621680966375"><span class="hs-identifier hs-var">st</span></a></span><span>
</span><span id="line-2802"></span><span>                     </span><span class="annot"><span class="annottext">SpecState -&gt; State SpecState ()
forall s. s -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#put"><span class="hs-identifier hs-var">put</span></a></span><span> </span><span class="annot"><span class="annottext">(SpecState -&gt; State SpecState ())
-&gt; SpecState -&gt; State SpecState ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SpecState
</span><a href="#local-6989586621680966375"><span class="hs-identifier hs-var">st</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">spec_uniq_supply :: UniqSupply
</span><a href="GHC.Core.Opt.Specialise.html#spec_uniq_supply"><span class="hs-identifier hs-var">spec_uniq_supply</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966372"><span class="hs-identifier hs-var">us2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2803"></span><span>                     </span><span class="annot"><span class="annottext">UniqSupply -&gt; State SpecState UniqSupply
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966373"><span class="hs-identifier hs-var">us1</span></a></span><span>
</span><span id="line-2804"></span><span>
</span><span id="line-2805"></span><span>    </span><span id="local-6989586621680966366"><span class="annot"><span class="annottext">getUniqueM :: SpecM Unique
</span><a href="#local-6989586621680966366"><span class="hs-identifier hs-var hs-var hs-var hs-var">getUniqueM</span></a></span></span><span>
</span><span id="line-2806"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State SpecState Unique -&gt; SpecM Unique
forall a. State SpecState a -&gt; SpecM a
</span><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-var">SpecM</span></a></span><span> </span><span class="annot"><span class="annottext">(State SpecState Unique -&gt; SpecM Unique)
-&gt; State SpecState Unique -&gt; SpecM Unique
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621680966365"><span class="annot"><span class="annottext">SpecState
</span><a href="#local-6989586621680966365"><span class="hs-identifier hs-var">st</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">State SpecState SpecState
forall s. State s s
</span><a href="GHC.Utils.Monad.State.html#get"><span class="hs-identifier hs-var">get</span></a></span><span>
</span><span id="line-2807"></span><span>                     </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966364"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680966364"><span class="hs-identifier hs-var">u</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680966363"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966363"><span class="hs-identifier hs-var">us'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSupply -&gt; (Unique, UniqSupply)
</span><a href="GHC.Types.Unique.Supply.html#takeUniqFromSupply"><span class="hs-identifier hs-var">takeUniqFromSupply</span></a></span><span> </span><span class="annot"><span class="annottext">(UniqSupply -&gt; (Unique, UniqSupply))
-&gt; UniqSupply -&gt; (Unique, UniqSupply)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SpecState -&gt; UniqSupply
</span><a href="GHC.Core.Opt.Specialise.html#spec_uniq_supply"><span class="hs-identifier hs-var hs-var">spec_uniq_supply</span></a></span><span> </span><span class="annot"><span class="annottext">SpecState
</span><a href="#local-6989586621680966365"><span class="hs-identifier hs-var">st</span></a></span><span>
</span><span id="line-2808"></span><span>                     </span><span class="annot"><span class="annottext">SpecState -&gt; State SpecState ()
forall s. s -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#put"><span class="hs-identifier hs-var">put</span></a></span><span> </span><span class="annot"><span class="annottext">(SpecState -&gt; State SpecState ())
-&gt; SpecState -&gt; State SpecState ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SpecState
</span><a href="#local-6989586621680966365"><span class="hs-identifier hs-var">st</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">spec_uniq_supply :: UniqSupply
</span><a href="GHC.Core.Opt.Specialise.html#spec_uniq_supply"><span class="hs-identifier hs-var">spec_uniq_supply</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966363"><span class="hs-identifier hs-var">us'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2809"></span><span>                     </span><span class="annot"><span class="annottext">Unique -&gt; State SpecState Unique
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680966364"><span class="hs-identifier hs-var">u</span></a></span><span>
</span><span id="line-2810"></span><span>
</span><span id="line-2811"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#HasDynFlags"><span class="hs-identifier hs-type">HasDynFlags</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2812"></span><span>    </span><span id="local-6989586621680966358"><span class="annot"><span class="annottext">getDynFlags :: SpecM DynFlags
</span><a href="#local-6989586621680966358"><span class="hs-identifier hs-var hs-var hs-var hs-var">getDynFlags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State SpecState DynFlags -&gt; SpecM DynFlags
forall a. State SpecState a -&gt; SpecM a
</span><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-var">SpecM</span></a></span><span> </span><span class="annot"><span class="annottext">(State SpecState DynFlags -&gt; SpecM DynFlags)
-&gt; State SpecState DynFlags -&gt; SpecM DynFlags
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(SpecState -&gt; DynFlags)
-&gt; State SpecState SpecState -&gt; State SpecState DynFlags
forall (m :: * -&gt; *) a1 r. Monad m =&gt; (a1 -&gt; r) -&gt; m a1 -&gt; m r
</span><a href="../../base/src/GHC.Base.html#liftM"><span class="hs-identifier hs-var">liftM</span></a></span><span> </span><span class="annot"><span class="annottext">SpecState -&gt; DynFlags
</span><a href="GHC.Core.Opt.Specialise.html#spec_dflags"><span class="hs-identifier hs-var hs-var">spec_dflags</span></a></span><span> </span><span class="annot"><span class="annottext">State SpecState SpecState
forall s. State s s
</span><a href="GHC.Utils.Monad.State.html#get"><span class="hs-identifier hs-var">get</span></a></span><span>
</span><span id="line-2813"></span><span>
</span><span id="line-2814"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html#HasModule"><span class="hs-identifier hs-type">HasModule</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2815"></span><span>    </span><span id="local-6989586621680966353"><span class="annot"><span class="annottext">getModule :: SpecM Module
</span><a href="#local-6989586621680966353"><span class="hs-identifier hs-var hs-var hs-var hs-var">getModule</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State SpecState Module -&gt; SpecM Module
forall a. State SpecState a -&gt; SpecM a
</span><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-var">SpecM</span></a></span><span> </span><span class="annot"><span class="annottext">(State SpecState Module -&gt; SpecM Module)
-&gt; State SpecState Module -&gt; SpecM Module
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(SpecState -&gt; Module)
-&gt; State SpecState SpecState -&gt; State SpecState Module
forall (m :: * -&gt; *) a1 r. Monad m =&gt; (a1 -&gt; r) -&gt; m a1 -&gt; m r
</span><a href="../../base/src/GHC.Base.html#liftM"><span class="hs-identifier hs-var">liftM</span></a></span><span> </span><span class="annot"><span class="annottext">SpecState -&gt; Module
</span><a href="GHC.Core.Opt.Specialise.html#spec_module"><span class="hs-identifier hs-var hs-var">spec_module</span></a></span><span> </span><span class="annot"><span class="annottext">State SpecState SpecState
forall s. State s s
</span><a href="GHC.Utils.Monad.State.html#get"><span class="hs-identifier hs-var">get</span></a></span><span>
</span><span id="line-2816"></span><span>
</span><span id="line-2817"></span><span id="local-6989586621680967811"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#runSpecM"><span class="hs-identifier hs-type">runSpecM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier hs-type">Module</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680967811"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#CoreM"><span class="hs-identifier hs-type">CoreM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680967811"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-2818"></span><span id="runSpecM"><span class="annot"><span class="annottext">runSpecM :: forall a. DynFlags -&gt; Module -&gt; SpecM a -&gt; CoreM a
</span><a href="GHC.Core.Opt.Specialise.html#runSpecM"><span class="hs-identifier hs-var hs-var">runSpecM</span></a></span></span><span> </span><span id="local-6989586621680966348"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680966348"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680966347"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680966347"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span id="local-6989586621680966346"><span class="annot"><span class="annottext">State SpecState a
</span><a href="#local-6989586621680966346"><span class="hs-identifier hs-var">spec</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2819"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621680966345"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966345"><span class="hs-identifier hs-var">us</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreM UniqSupply
forall (m :: * -&gt; *). MonadUnique m =&gt; m UniqSupply
</span><a href="GHC.Types.Unique.Supply.html#getUniqueSupplyM"><span class="hs-identifier hs-var">getUniqueSupplyM</span></a></span><span>
</span><span id="line-2820"></span><span>         </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680966344"><span class="annot"><span class="annottext">initialState :: SpecState
</span><a href="#local-6989586621680966344"><span class="hs-identifier hs-var hs-var">initialState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecState :: UniqSupply -&gt; Module -&gt; DynFlags -&gt; SpecState
</span><a href="GHC.Core.Opt.Specialise.html#SpecState"><span class="hs-identifier hs-type">SpecState</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-2821"></span><span>                                </span><span class="annot"><span class="annottext">spec_uniq_supply :: UniqSupply
</span><a href="GHC.Core.Opt.Specialise.html#spec_uniq_supply"><span class="hs-identifier hs-var">spec_uniq_supply</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966345"><span class="hs-identifier hs-var">us</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-2822"></span><span>                                </span><span class="annot"><span class="annottext">spec_module :: Module
</span><a href="GHC.Core.Opt.Specialise.html#spec_module"><span class="hs-identifier hs-var">spec_module</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621680966347"><span class="hs-identifier hs-var">this_mod</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-2823"></span><span>                                </span><span class="annot"><span class="annottext">spec_dflags :: DynFlags
</span><a href="GHC.Core.Opt.Specialise.html#spec_dflags"><span class="hs-identifier hs-var">spec_dflags</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680966348"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-2824"></span><span>                            </span><span class="hs-special">}</span><span>
</span><span id="line-2825"></span><span>         </span><span class="annot"><span class="annottext">a -&gt; CoreM a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; CoreM a) -&gt; a -&gt; CoreM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">State SpecState a -&gt; SpecState -&gt; a
forall s a. State s a -&gt; s -&gt; a
</span><a href="GHC.Utils.Monad.State.html#evalState"><span class="hs-identifier hs-var">evalState</span></a></span><span> </span><span class="annot"><span class="annottext">State SpecState a
</span><a href="#local-6989586621680966346"><span class="hs-identifier hs-var">spec</span></a></span><span> </span><span class="annot"><span class="annottext">SpecState
</span><a href="#local-6989586621680966344"><span class="hs-identifier hs-var">initialState</span></a></span><span>
</span><span id="line-2826"></span><span>
</span><span id="line-2827"></span><span id="local-6989586621680967733"><span id="local-6989586621680967734"><span class="annot"><a href="GHC.Core.Opt.Specialise.html#mapAndCombineSM"><span class="hs-identifier hs-type">mapAndCombineSM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680967734"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680967733"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680967734"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680967733"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#UsageDetails"><span class="hs-identifier hs-type">UsageDetails</span></a></span><span class="hs-special">)</span></span></span><span>
</span><span id="line-2828"></span><span id="mapAndCombineSM"><span class="annot"><span class="annottext">mapAndCombineSM :: forall a b.
(a -&gt; SpecM (b, UsageDetails)) -&gt; [a] -&gt; SpecM ([b], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#mapAndCombineSM"><span class="hs-identifier hs-var hs-var">mapAndCombineSM</span></a></span></span><span> </span><span class="annot"><span class="annottext">a -&gt; SpecM (b, UsageDetails)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([b], UsageDetails) -&gt; SpecM ([b], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#emptyUDs"><span class="hs-identifier hs-var">emptyUDs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2829"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#mapAndCombineSM"><span class="hs-identifier hs-var">mapAndCombineSM</span></a></span><span> </span><span id="local-6989586621680966338"><span class="annot"><span class="annottext">a -&gt; SpecM (b, UsageDetails)
</span><a href="#local-6989586621680966338"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966337"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680966337"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680966336"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680966336"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966335"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680966335"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966334"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966334"><span class="hs-identifier hs-var">uds1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">a -&gt; SpecM (b, UsageDetails)
</span><a href="#local-6989586621680966338"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680966337"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-2830"></span><span>                              </span><span class="hs-special">(</span><span id="local-6989586621680966333"><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621680966333"><span class="hs-identifier hs-var">ys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966332"><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966332"><span class="hs-identifier hs-var">uds2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(a -&gt; SpecM (b, UsageDetails)) -&gt; [a] -&gt; SpecM ([b], UsageDetails)
forall a b.
(a -&gt; SpecM (b, UsageDetails)) -&gt; [a] -&gt; SpecM ([b], UsageDetails)
</span><a href="GHC.Core.Opt.Specialise.html#mapAndCombineSM"><span class="hs-identifier hs-var">mapAndCombineSM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; SpecM (b, UsageDetails)
</span><a href="#local-6989586621680966338"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680966336"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-2831"></span><span>                              </span><span class="annot"><span class="annottext">([b], UsageDetails) -&gt; SpecM ([b], UsageDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680966335"><span class="hs-identifier hs-var">y</span></a></span><span class="annot"><span class="annottext">b -&gt; [b] -&gt; [b]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621680966333"><span class="hs-identifier hs-var">ys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966334"><span class="hs-identifier hs-var">uds1</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails -&gt; UsageDetails -&gt; UsageDetails
</span><a href="GHC.Core.Opt.Specialise.html#plusUDs"><span class="hs-operator hs-var">`plusUDs`</span></a></span><span> </span><span class="annot"><span class="annottext">UsageDetails
</span><a href="#local-6989586621680966332"><span class="hs-identifier hs-var">uds2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2832"></span><span>
</span><span id="line-2833"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#extendTvSubstList"><span class="hs-identifier hs-type">extendTvSubstList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span>
</span><span id="line-2834"></span><span id="extendTvSubstList"><span class="annot"><span class="annottext">extendTvSubstList :: SpecEnv -&gt; [(Id, Type)] -&gt; SpecEnv
</span><a href="GHC.Core.Opt.Specialise.html#extendTvSubstList"><span class="hs-identifier hs-var hs-var">extendTvSubstList</span></a></span></span><span> </span><span id="local-6989586621680966330"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966330"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966329"><span class="annot"><span class="annottext">[(Id, Type)]
</span><a href="#local-6989586621680966329"><span class="hs-identifier hs-var">tv_binds</span></a></span></span><span>
</span><span id="line-2835"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966330"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [(Id, Type)] -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendTvSubstList"><span class="hs-identifier hs-var">Core.extendTvSubstList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var hs-var">se_subst</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966330"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Id, Type)]
</span><a href="#local-6989586621680966329"><span class="hs-identifier hs-var">tv_binds</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2836"></span><span>
</span><span id="line-2837"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#substTy"><span class="hs-identifier hs-type">substTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-2838"></span><span id="substTy"><span class="annot"><span class="annottext">substTy :: SpecEnv -&gt; Type -&gt; Type
</span><a href="GHC.Core.Opt.Specialise.html#substTy"><span class="hs-identifier hs-var hs-var">substTy</span></a></span></span><span> </span><span id="local-6989586621680966327"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966327"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966326"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966326"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">Core.substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var hs-var">se_subst</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966327"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966326"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2839"></span><span>
</span><span id="line-2840"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#substCo"><span class="hs-identifier hs-type">substCo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-2841"></span><span id="substCo"><span class="annot"><span class="annottext">substCo :: SpecEnv -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Opt.Specialise.html#substCo"><span class="hs-identifier hs-var hs-var">substCo</span></a></span></span><span> </span><span id="local-6989586621680966324"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966324"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966323"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680966323"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; Subst -&gt; Coercion -&gt; Coercion
Subst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-var">Core.substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var hs-var">se_subst</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966324"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680966323"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-2842"></span><span>
</span><span id="line-2843"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#substBndr"><span class="hs-identifier hs-type">substBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2844"></span><span id="substBndr"><span class="annot"><span class="annottext">substBndr :: SpecEnv -&gt; Id -&gt; (SpecEnv, Id)
</span><a href="GHC.Core.Opt.Specialise.html#substBndr"><span class="hs-identifier hs-var hs-var">substBndr</span></a></span></span><span> </span><span id="local-6989586621680966321"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966321"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966320"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966320"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier hs-var">Core.substBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var hs-var">se_subst</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966321"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966320"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2845"></span><span>                      </span><span class="hs-special">(</span><span id="local-6989586621680966318"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966318"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966317"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966317"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966321"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966318"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966317"><span class="hs-identifier hs-var">bs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2846"></span><span>
</span><span id="line-2847"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#substBndrs"><span class="hs-identifier hs-type">substBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2848"></span><span id="substBndrs"><span class="annot"><span class="annottext">substBndrs :: SpecEnv -&gt; [Id] -&gt; (SpecEnv, [Id])
</span><a href="GHC.Core.Opt.Specialise.html#substBndrs"><span class="hs-identifier hs-var hs-var">substBndrs</span></a></span></span><span> </span><span id="local-6989586621680966316"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966316"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966315"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966315"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substBndrs"><span class="hs-identifier hs-var">Core.substBndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var hs-var">se_subst</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966316"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966315"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2849"></span><span>                      </span><span class="hs-special">(</span><span id="local-6989586621680966313"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966313"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966312"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966312"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966316"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966313"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966312"><span class="hs-identifier hs-var">bs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2850"></span><span>
</span><span id="line-2851"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#cloneBindSM"><span class="hs-identifier hs-type">cloneBindSM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2852"></span><span class="hs-comment">-- Clone the binders of the bind; return new bind with the cloned binders</span><span>
</span><span id="line-2853"></span><span class="hs-comment">-- Return the substitution to use for RHSs, and the one to use for the body</span><span>
</span><span id="line-2854"></span><span id="cloneBindSM"><span class="annot"><span class="annottext">cloneBindSM :: SpecEnv -&gt; CoreBind -&gt; SpecM (SpecEnv, SpecEnv, CoreBind)
</span><a href="GHC.Core.Opt.Specialise.html#cloneBindSM"><span class="hs-identifier hs-var hs-var">cloneBindSM</span></a></span></span><span> </span><span id="local-6989586621680966311"><span class="annot"><span class="annottext">env :: SpecEnv
</span><a href="#local-6989586621680966311"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SE"><span class="hs-identifier hs-type">SE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966310"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966310"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">se_interesting :: SpecEnv -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var">se_interesting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966309"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966309"><span class="hs-identifier hs-var">interesting</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680966308"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966308"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680966307"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966307"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2855"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680966306"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966306"><span class="hs-identifier hs-var">us</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecM UniqSupply
forall (m :: * -&gt; *). MonadUnique m =&gt; m UniqSupply
</span><a href="GHC.Types.Unique.Supply.html#getUniqueSupplyM"><span class="hs-identifier hs-var">getUniqueSupplyM</span></a></span><span>
</span><span id="line-2856"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966305"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966305"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966304"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966304"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; UniqSupply -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#cloneIdBndr"><span class="hs-identifier hs-var">Core.cloneIdBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966310"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966306"><span class="hs-identifier hs-var">us</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966308"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-2857"></span><span>             </span><span id="local-6989586621680966302"><span class="annot"><span class="annottext">interesting' :: VarSet
</span><a href="#local-6989586621680966302"><span class="hs-identifier hs-var hs-var">interesting'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966311"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966307"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-2858"></span><span>                          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966309"><span class="hs-identifier hs-var">interesting</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966304"><span class="hs-identifier hs-var">bndr'</span></a></span><span>
</span><span id="line-2859"></span><span>                          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966309"><span class="hs-identifier hs-var">interesting</span></a></span><span>
</span><span id="line-2860"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(SpecEnv, SpecEnv, CoreBind) -&gt; SpecM (SpecEnv, SpecEnv, CoreBind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966311"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966311"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966305"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">se_interesting :: VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var">se_interesting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966302"><span class="hs-identifier hs-var">interesting'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2861"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966304"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966307"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2862"></span><span>
</span><span id="line-2863"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#cloneBindSM"><span class="hs-identifier hs-var">cloneBindSM</span></a></span><span> </span><span id="local-6989586621680966301"><span class="annot"><span class="annottext">env :: SpecEnv
</span><a href="#local-6989586621680966301"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SE"><span class="hs-identifier hs-type">SE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: SpecEnv -&gt; Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966300"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966300"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">se_interesting :: SpecEnv -&gt; VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var">se_interesting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680966299"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966299"><span class="hs-identifier hs-var">interesting</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680966298"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966298"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2864"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680966297"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966297"><span class="hs-identifier hs-var">us</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecM UniqSupply
forall (m :: * -&gt; *). MonadUnique m =&gt; m UniqSupply
</span><a href="GHC.Types.Unique.Supply.html#getUniqueSupplyM"><span class="hs-identifier hs-var">getUniqueSupplyM</span></a></span><span>
</span><span id="line-2865"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966296"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966296"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680966295"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966295"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; UniqSupply -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#cloneRecIdBndrs"><span class="hs-identifier hs-var">Core.cloneRecIdBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966300"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680966297"><span class="hs-identifier hs-var">us</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Id, CoreExpr) -&gt; Id) -&gt; [(Id, CoreExpr)] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; Id
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966298"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2866"></span><span>             </span><span id="local-6989586621680966293"><span class="annot"><span class="annottext">env' :: SpecEnv
</span><a href="#local-6989586621680966293"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966301"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">se_subst :: Subst
</span><a href="GHC.Core.Opt.Specialise.html#se_subst"><span class="hs-identifier hs-var">se_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680966296"><span class="hs-identifier hs-var">subst'</span></a></span><span>
</span><span id="line-2867"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">se_interesting :: VarSet
</span><a href="GHC.Core.Opt.Specialise.html#se_interesting"><span class="hs-identifier hs-var">se_interesting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680966299"><span class="hs-identifier hs-var">interesting</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSetList"><span class="hs-operator hs-var">`extendVarSetList`</span></a></span><span>
</span><span id="line-2868"></span><span>                                           </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966292"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680966292"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966292"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680966291"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966291"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966298"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Opt.Specialise.html#interestingDict"><span class="hs-identifier hs-var">interestingDict</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966301"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680966291"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2869"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(SpecEnv, SpecEnv, CoreBind) -&gt; SpecM (SpecEnv, SpecEnv, CoreBind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966293"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966293"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680966295"><span class="hs-identifier hs-var">bndrs'</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [CoreExpr] -&gt; [(Id, CoreExpr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">((Id, CoreExpr) -&gt; CoreExpr) -&gt; [(Id, CoreExpr)] -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; CoreExpr
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680966298"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2870"></span><span>
</span><span id="line-2871"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#newDictBndr"><span class="hs-identifier hs-type">newDictBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecEnv"><span class="hs-identifier hs-type">SpecEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span>
</span><span id="line-2872"></span><span class="hs-comment">-- Make up completely fresh binders for the dictionaries</span><span>
</span><span id="line-2873"></span><span class="hs-comment">-- Their bindings are going to float outwards</span><span>
</span><span id="line-2874"></span><span id="newDictBndr"><span class="annot"><span class="annottext">newDictBndr :: SpecEnv -&gt; Id -&gt; SpecM Id
</span><a href="GHC.Core.Opt.Specialise.html#newDictBndr"><span class="hs-identifier hs-var hs-var">newDictBndr</span></a></span></span><span> </span><span id="local-6989586621680966290"><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966290"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680966289"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966289"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680966288"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680966288"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecM Unique
forall (m :: * -&gt; *). MonadUnique m =&gt; m Unique
</span><a href="GHC.Types.Unique.Supply.html#getUniqueM"><span class="hs-identifier hs-var">getUniqueM</span></a></span><span>
</span><span id="line-2875"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680966287"><span class="annot"><span class="annottext">n :: Name
</span><a href="#local-6989586621680966287"><span class="hs-identifier hs-var hs-var">n</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966289"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-2876"></span><span>                              </span><span id="local-6989586621680966286"><span class="annot"><span class="annottext">ty' :: Type
</span><a href="#local-6989586621680966286"><span class="hs-identifier hs-var hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpecEnv -&gt; Type -&gt; Type
</span><a href="GHC.Core.Opt.Specialise.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">SpecEnv
</span><a href="#local-6989586621680966290"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966289"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2877"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SpecM Id
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; Unique -&gt; Type -&gt; Type -&gt; SrcSpan -&gt; Id
</span><a href="GHC.Types.Id.html#mkUserLocal"><span class="hs-identifier hs-var">mkUserLocal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680966287"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680966288"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966286"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680966287"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2878"></span><span>
</span><span id="line-2879"></span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#newSpecIdSM"><span class="hs-identifier hs-type">newSpecIdSM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Specialise.html#SpecM"><span class="hs-identifier hs-type">SpecM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-2880"></span><span>    </span><span class="hs-comment">-- Give the new Id a similar occurrence name to the old one</span><span>
</span><span id="line-2881"></span><span id="newSpecIdSM"><span class="annot"><span class="annottext">newSpecIdSM :: Id -&gt; Type -&gt; Maybe Int -&gt; SpecM Id
</span><a href="GHC.Core.Opt.Specialise.html#newSpecIdSM"><span class="hs-identifier hs-var hs-var">newSpecIdSM</span></a></span></span><span> </span><span id="local-6989586621680966282"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966282"><span class="hs-identifier hs-var">old_id</span></a></span></span><span> </span><span id="local-6989586621680966281"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966281"><span class="hs-identifier hs-var">new_ty</span></a></span></span><span> </span><span id="local-6989586621680966280"><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680966280"><span class="hs-identifier hs-var">join_arity_maybe</span></a></span></span><span>
</span><span id="line-2882"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680966279"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680966279"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SpecM Unique
forall (m :: * -&gt; *). MonadUnique m =&gt; m Unique
</span><a href="GHC.Types.Unique.Supply.html#getUniqueM"><span class="hs-identifier hs-var">getUniqueM</span></a></span><span>
</span><span id="line-2883"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680966278"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621680966278"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966282"><span class="hs-identifier hs-var">old_id</span></a></span><span>
</span><span id="line-2884"></span><span>              </span><span id="local-6989586621680966277"><span class="annot"><span class="annottext">new_occ :: OccName
</span><a href="#local-6989586621680966277"><span class="hs-identifier hs-var hs-var">new_occ</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkSpecOcc"><span class="hs-identifier hs-var">mkSpecOcc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680966278"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2885"></span><span>              </span><span id="local-6989586621680966274"><span class="annot"><span class="annottext">new_id :: Id
</span><a href="#local-6989586621680966274"><span class="hs-identifier hs-var hs-var">new_id</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; Unique -&gt; Type -&gt; Type -&gt; SrcSpan -&gt; Id
</span><a href="GHC.Types.Id.html#mkUserLocal"><span class="hs-identifier hs-var">mkUserLocal</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621680966277"><span class="hs-identifier hs-var">new_occ</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680966279"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680966281"><span class="hs-identifier hs-var">new_ty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680966278"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2886"></span><span>                          </span><span class="annot"><span class="annottext">Id -&gt; Maybe Int -&gt; Id
</span><a href="GHC.Types.Id.html#asJoinId_maybe"><span class="hs-operator hs-var">`asJoinId_maybe`</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680966280"><span class="hs-identifier hs-var">join_arity_maybe</span></a></span><span>
</span><span id="line-2887"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SpecM Id
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680966274"><span class="hs-identifier hs-var">new_id</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2888"></span><span>
</span><span id="line-2889"></span><span class="hs-comment">{-
                Old (but interesting) stuff about unboxed bindings
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What should we do when a value is specialised to a *strict* unboxed value?

        map_*_* f (x:xs) = let h = f x
                               t = map f xs
                           in h:t

Could convert let to case:

        map_*_Int# f (x:xs) = case f x of h# -&gt;
                              let t = map f xs
                              in h#:t

This may be undesirable since it forces evaluation here, but the value
may not be used in all branches of the body. In the general case this
transformation is impossible since the mutual recursion in a letrec
cannot be expressed as a case.

There is also a problem with top-level unboxed values, since our
implementation cannot handle unboxed values at the top level.

Solution: Lift the binding of the unboxed value and extract it when it
is used:

        map_*_Int# f (x:xs) = let h = case (f x) of h# -&gt; _Lift h#
                                  t = map f xs
                              in case h of
                                 _Lift h# -&gt; h#:t

Now give it to the simplifier and the _Lifting will be optimised away.

The benefit is that we have given the specialised &quot;unboxed&quot; values a
very simple lifted semantics and then leave it up to the simplifier to
optimise it --- knowing that the overheads will be removed in nearly
all cases.

In particular, the value will only be evaluated in the branches of the
program which use it, rather than being forced at the point where the
value is bound. For example:

        filtermap_*_* p f (x:xs)
          = let h = f x
                t = ...
            in case p x of
                True  -&gt; h:t
                False -&gt; t
   ==&gt;
        filtermap_*_Int# p f (x:xs)
          = let h = case (f x) of h# -&gt; _Lift h#
                t = ...
            in case p x of
                True  -&gt; case h of _Lift h#
                           -&gt; h#:t
                False -&gt; t

The binding for h can still be inlined in the one branch and the
_Lifting eliminated.


Question: When won't the _Lifting be eliminated?

Answer: When they at the top-level (where it is necessary) or when
inlining would duplicate work (or possibly code depending on
options). However, the _Lifting will still be eliminated if the
strictness analyser deems the lifted binding strict.
-}</span><span>
</span><span id="line-2958"></span></pre></body></html>